1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-09 08:58:35 +03:00

Fixed parsing issue with HP printer defs reported by HP.

Jeremy.
This commit is contained in:
Jeremy Allison -
parent b183c24220
commit 035272e6bc

View File

@ -350,26 +350,62 @@ static void scan_copyfiles(FILE *fichier, char *chaine)
*
* pscript.hlp = pscript.hl_
* hpdcmon.dll,hpdcmon.dl_
* MSVCRT.DLL,MSVCRT.DL_,,32
* ctl3dv2.dll,ctl3dv2.dl_,ctl3dv2.tmp
*
* In the first 2 cases you want the first file name - in the last case
* you only want the last file name (at least that is what a Win95
* machine sent). This may still be wrong but at least I get the same list
* machine sent). In the third case you also want the first file name
* (detect by the last component being just a number ?).
* This may still be wrong but at least I get the same list
* of files as seen on a printer test page.
*/
part = strchr(buffer[i],'=');
if (part) {
/*
* Case (1) eg. pscript.hlp = pscript.hl_ - chop after the first name.
*/
*part = '\0';
while (--part > buffer[i])
if ((*part == ' ') || (*part =='\t')) *part = '\0';
else break;
/*
* Now move back to the start and print that.
*/
while (--part > buffer[i]) {
if ((*part == ' ') || (*part =='\t'))
*part = '\0';
else
break;
}
} else {
part = strchr(buffer[i],',');
if (part) {
/*
* Cases (2-4)
*/
if ((mpart = strrchr(part+1,','))!=NULL) {
/*
* Second ',' - case 3 or 4.
* Check if the last part is just a number,
* if so we need the first part.
*/
char *endptr = NULL;
BOOL isnumber = False;
mpart++;
(void)strtol(mpart, &endptr, 10);
isnumber = ((endptr > mpart) && isdigit(*mpart));
if(!isnumber)
pstrcpy(buffer[i],mpart+1);
} else
else
*part = '\0';
} else {
*part = '\0';
}
while (--part > buffer[i])
if ((*part == ' ') || (*part =='\t')) *part = '\0';
else break;
@ -383,15 +419,15 @@ static void scan_copyfiles(FILE *fichier, char *chaine)
fprintf(stderr,"%s%s\n",direc,buffer[i]);
}
i++;
}
} /* end while */
}
part=strtok(NULL,",");
if (part)
if (part) {
while( *part ==' ' && *part != '\0') {
part++;
}
}
while (part!=NULL);
} while (part!=NULL);
fprintf(stderr,"\n");
}