correcting a very nasty trim bug

This commit is contained in:
Tonton Th 2019-11-01 16:25:42 +01:00
parent 134f3170f6
commit ec27a42dc1

View File

@ -17,7 +17,7 @@ int verbosity;
/* --------------------------------------------------------------------- */
void affiche_un_sample(SampleRef *sref)
{
printf("%c %02X [%-20s] %s\n", sref->key, sref->flags, sref->text,
printf("%c %02X [%-20s] %s\n", sref->key, sref->flags, sref->text,
sref->path);
}
/* --------------------------------------------------------------------- */
@ -60,12 +60,13 @@ if (NULL==ptr) {
fprintf(stderr, "line to short\n");
return -6;
}
if (verbosity) fprintf(stderr, "path [%s]\n", ltrim(rtrim(ptr)));
if (strlen(ptr) > SZ_TEXT) {
cp = ltrim(rtrim(ptr));
if (verbosity) fprintf(stderr, "path [%s]\n", cp);
if (strlen(ptr) > SZ_PATH) {
fprintf(stderr, "path too long\n");
return -5;
}
strcpy(sref->path, ptr);
strcpy(sref->path, cp);
return 0;
}
@ -105,7 +106,9 @@ while (NULL != fgets(line, T_LINE, fp)) {
memset(&sample, 0, sizeof(SampleRef));
foo = decode_la_ligne(line, &sample);
#if DEBUG_LEVEL
fprintf(stderr, "decode la ligne -> %d\n\n", foo);
#endif
affiche_un_sample(&sample);
ln++;