save a bit of code with *strchrnul = '\0' trick

function                                             old     new   delta
nextline                                              59      55      -4
include_conf                                         902     898      -4
read_config                                          414     406      -8
fsck_main                                           1880    1869     -11
This commit is contained in:
Denis Vlasenko
2007-12-26 20:56:55 +00:00
parent abee3d0e0d
commit c03e872112
5 changed files with 8 additions and 19 deletions

View File

@@ -332,14 +332,12 @@ int read_config(const char *file)
while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) {
char debug_orig[READ_CONFIG_BUF_SIZE];
char *p;
lm++;
p = strchr(buffer, '\n');
if (p) *p = '\0';
if (ENABLE_FEATURE_UDHCP_DEBUG) strcpy(debug_orig, buffer);
p = strchr(buffer, '#');
if (p) *p = '\0';
*strchrnul(buffer, '\n') = '\0';
if (ENABLE_FEATURE_UDHCP_DEBUG)
strcpy(debug_orig, buffer);
*strchrnul(buffer, '#') = '\0';
token = strtok(buffer, " \t");
if (!token) continue;