projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
whatnow2 handle mhuse
[mmh]
/
sbr
/
m_getfld2.c
diff --git
a/sbr/m_getfld2.c
b/sbr/m_getfld2.c
index
18ad812
..
b9a618d
100644
(file)
--- a/
sbr/m_getfld2.c
+++ b/
sbr/m_getfld2.c
@@
-10,7
+10,6
@@
#include <h/utils.h>
#include <stdio.h>
#include <ctype.h>
#include <h/utils.h>
#include <stdio.h>
#include <ctype.h>
-#include <stdbool.h>
enum threestate {
enum threestate {
@@
-24,7
+23,7
@@
enum threestate {
*/
static enum threestate is_falted(FILE *);
static size_t copyname(char *, char *);
*/
static enum threestate is_falted(FILE *);
static size_t copyname(char *, char *);
-static bool is_separator(char *);
+static boolean is_separator(char *);
/*
/*
@@
-63,7
+62,8
@@
m_getfld2(enum state s, struct field *f, FILE *msg)
}
}
}
}
- if (nchars >= NAMESZ) {
+ f->crlf = (nchars > 2 && tmpline[nchars-2] == '\r');
+ if (nchars > NAMESZ+1 || (!f->crlf && nchars > NAMESZ)) {
ret = LENERR2;
}
ret = LENERR2;
}
@@
-97,14
+97,14
@@
m_getfld2(enum state s, struct field *f, FILE *msg)
f->valuelen = nchars;
}
f->valuelen = nchars;
}
- while (ret == FLD2 && (falted = is_falted(msg)) == B_TRUE) {
+ while ((ret == FLD2 || ret == LENERR2) && (falted = is_falted(msg)) == B_TRUE) {
nchars = getline(&tmpline, &len, msg);
if (nchars <= 0) {
free(tmpline);
return IOERR2;
}
nchars = getline(&tmpline, &len, msg);
if (nchars <= 0) {
free(tmpline);
return IOERR2;
}
- if (nchars >= NAMESZ) {
+ if (nchars > NAMESZ+1 || (!f->crlf && nchars > NAMESZ)) {
ret = LENERR2;
}
ret = LENERR2;
}
@@
-146,10
+146,7
@@
m_getfld2(enum state s, struct field *f, FILE *msg)
}
}
}
}
- if (nchars >= NAMESZ) {
- ret = LENERR2;
- }
-
+ f->crlf = (nchars > 2 && tmpline[nchars-2] == '\r');
free(f->value);
f->value = tmpline;
f->valuelen = nchars;
free(f->value);
f->value = tmpline;
f->valuelen = nchars;
@@
-214,7
+211,7
@@
copyname(char *dst, char *src)
return strlen(dst);
}
return strlen(dst);
}
-static bool
+static boolean
is_separator(char *line)
{
/*
is_separator(char *line)
{
/*
@@
-225,7
+222,7
@@
is_separator(char *line)
line++;
}
if (strcmp("\n", line) == 0 || strcmp("\r\n", line) == 0 ) {
line++;
}
if (strcmp("\n", line) == 0 || strcmp("\r\n", line) == 0 ) {
- return true;
+ return TRUE;
}
}
- return false;
+ return FALSE;
}
}