niash: fix format string for gamma table debugging, slight rework

Avoid calling strcpy()/strcat() unnecessarily, kill intermediate buffer.
merge-requests/1/head
Julien BLACHE 2010-06-23 18:21:38 +02:00
rodzic 74509fc4cb
commit 0951e1b780
1 zmienionych plików z 4 dodań i 8 usunięć

Wyświetl plik

@ -986,7 +986,6 @@ sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action Action,
TScanner *s; TScanner *s;
SANE_Bool fVal; SANE_Bool fVal;
static char szTable[100]; static char szTable[100];
char szTemp[16];
int *pi; int *pi;
int i; int i;
SANE_Int info; SANE_Int info;
@ -1111,21 +1110,18 @@ sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action Action,
{ {
if ((SANE_GAMMA_SIZE / 16) && (i % (SANE_GAMMA_SIZE / 16)) == 0) if ((SANE_GAMMA_SIZE / 16) && (i % (SANE_GAMMA_SIZE / 16)) == 0)
{ {
strcat (szTable, "\n"); DBG (DBG_MSG, "%s\n", szTable);
DBG (DBG_MSG, szTable); szTable[0] = '\0';
strcpy (szTable, "");
} }
/* test for number print */ /* test for number print */
if ((SANE_GAMMA_SIZE / 64) && (i % (SANE_GAMMA_SIZE / 64)) == 0) if ((SANE_GAMMA_SIZE / 64) && (i % (SANE_GAMMA_SIZE / 64)) == 0)
{ {
sprintf (szTemp, " %04X", pi[i]); sprintf (szTable + strlen(szTable), " %04X", pi[i]);
strcat (szTable, szTemp);
} }
} }
if (strlen (szTable)) if (strlen (szTable))
{ {
strcat (szTable, "\n"); DBG (DBG_MSG, "%s\n", szTable);
DBG (DBG_MSG, szTable);
} }
break; break;