correcting a very nasty trim bug

This commit is contained in:
tth 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) 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); sref->path);
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -60,12 +60,13 @@ if (NULL==ptr) {
fprintf(stderr, "line to short\n"); fprintf(stderr, "line to short\n");
return -6; return -6;
} }
if (verbosity) fprintf(stderr, "path [%s]\n", ltrim(rtrim(ptr))); cp = ltrim(rtrim(ptr));
if (strlen(ptr) > SZ_TEXT) { if (verbosity) fprintf(stderr, "path [%s]\n", cp);
if (strlen(ptr) > SZ_PATH) {
fprintf(stderr, "path too long\n"); fprintf(stderr, "path too long\n");
return -5; return -5;
} }
strcpy(sref->path, ptr); strcpy(sref->path, cp);
return 0; return 0;
} }
@ -105,7 +106,9 @@ while (NULL != fgets(line, T_LINE, fp)) {
memset(&sample, 0, sizeof(SampleRef)); memset(&sample, 0, sizeof(SampleRef));
foo = decode_la_ligne(line, &sample); foo = decode_la_ligne(line, &sample);
#if DEBUG_LEVEL
fprintf(stderr, "decode la ligne -> %d\n\n", foo); fprintf(stderr, "decode la ligne -> %d\n\n", foo);
#endif
affiche_un_sample(&sample); affiche_un_sample(&sample);
ln++; ln++;