Added new keywords, random fixes

This commit is contained in:
Alexander S. Aganichev
2003-06-09 05:47:39 +00:00
parent 37e5560578
commit 824ad2730b
31 changed files with 743 additions and 48 deletions

View File

@@ -76,7 +76,8 @@ char * uunconc_id = "$Id$";
#define BEGIN (1)
#define DATA (2)
#define END (3)
#define DONE (4)
#define END2 (4)
#define DONE (5)
/*
* mallocable areas
@@ -1072,7 +1073,15 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
tc = tf = vlc = 0;
lc[0] = lc[1] = 0;
}
else if ((*state == END) &&
else if ((*state == END) && (method == UU_ENCODED)) {
if (strncmp (line, "`", 1) == 0)
*state = END2;
}
else if ((*state == END) && (method == XX_ENCODED)) {
if (strncmp (line, "+", 1) == 0)
*state = END2;
}
else if ((*state == END2) &&
(method == UU_ENCODED || method == XX_ENCODED)) {
if (strncmp (line, "end", 3) == 0) {
*state = DONE;
@@ -1117,7 +1126,7 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
break;
}
if (*state == DATA || *state == END) {
if (*state == DATA || *state == END || *state == END2) {
if (method==B64ENCODED && line[0]=='-' && line[1]=='-' && tc) {
break;
}
@@ -1173,9 +1182,9 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
}
if (method == UU_ENCODED)
*state = (line[0] == 'M') ? DATA : END;
*state = (line[0] == 'M') ? DATA : (line[0] == '`') ? END2 : END;
else if (method == XX_ENCODED)
*state = (line[0] == 'h') ? DATA : END;
*state = (line[0] == 'h') ? DATA : (line[0] == '+') ? END2 : END;
else if (method == B64ENCODED)
*state = (strchr (line, '=') == NULL) ? DATA : DONE;
else if (method == BH_ENCODED)

View File

@@ -525,6 +525,7 @@ ScanData (FILE *datei, char *fname, int *errcode,
long preheaders=0, oldposition;
long yefilesize=0, yepartends=0;
size_t dcc, bhopc;
char prevlinefirstchar;
*errcode = UURET_OK;
(void) UUDecodeLine (NULL, NULL, 0); /* init */
@@ -545,7 +546,9 @@ ScanData (FILE *datei, char *fname, int *errcode,
if (boundary)
blen = strlen (boundary);
line[0] = '\0';
while (!feof (datei)) {
prevlinefirstchar = line[0];
oldposition = ftell (datei);
if (_FP_fgets (line, 299, datei) == NULL)
break;
@@ -675,7 +678,17 @@ ScanData (FILE *datei, char *fname, int *errcode,
result->uudet = XX_ENCODED;
if (result->uudet != B64ENCODED) {
result->end = 1;
if (result->uudet == XX_ENCODED) {
if (prevlinefirstchar == '+')
result->end = 1;
}
if (result->uudet == UU_ENCODED) {
if (prevlinefirstchar == '`')
result->end = 1;
}
else {
result->end = 1;
}
if (dflag && encoding)
result->uudet = encoding;
continue;
@@ -839,6 +852,7 @@ ScanData (FILE *datei, char *fname, int *errcode,
(((ptr = _FP_strrstr (line+2, "--")) == NULL) ||
(*(ptr+2) != '\012' && *(ptr+2) != '\015')) &&
_FP_strstr (line+2, "_=_") != NULL) {
prevlinefirstchar = line[0];
if (_FP_fgets (line, 255, datei) == NULL) {
break;
}
@@ -1096,6 +1110,7 @@ ScanData (FILE *datei, char *fname, int *errcode,
break;
}
prevlinefirstchar = line[0];
oldposition = ftell (datei);
if (_FP_fgets (line, 255, datei) == NULL)
break;
@@ -1117,8 +1132,18 @@ ScanData (FILE *datei, char *fname, int *errcode,
else if (line[0] == 'e' && (result->uudet == UU_ENCODED ||
result->uudet == XX_ENCODED)) {
if (strncmp (line, "end", 3) == 0) {
result->end = 1;
break;
if (result->uudet == XX_ENCODED) {
if (prevlinefirstchar == '+') {
result->end = 1;
break;
}
}
else {
if (prevlinefirstchar == '`') {
result->end = 1;
break;
}
}
}
}
else if (line[0] == 'b') {