]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - util.c
Don't use strcmp to check strings one or zero characters long
[thirdparty/sarg.git] / util.c
diff --git a/util.c b/util.c
index 0c4083bc9e35b9efd0569e4912665a1d9c962e73..2291ca45a07652d779b07d434962130fb2401a11 100644 (file)
--- a/util.c
+++ b/util.c
@@ -954,11 +954,11 @@ int getperiod_buildtext(struct periodstruct *period)
        int range;
        char text1[40], text2[40];
 
-       if(df[0]=='u') {
+       if (df=='u') {
                i=strftime(text1, sizeof(text1), "%Y %b %d", &period->start);
-       }else if(df[0]=='e') {
+       } else if(df=='e') {
                i=strftime(text1, sizeof(text1), "%d %b %Y", &period->start);
-       } else /*if(df[0]=='w')*/ {
+       } else /*if (df=='w')*/ {
                IndexTree=INDEX_TREE_FILE;
                i=strftime(text1, sizeof(text1), "%Y.%U", &period->start);
        }
@@ -968,9 +968,9 @@ int getperiod_buildtext(struct periodstruct *period)
               period->start.tm_mon!=period->end.tm_mon ||
               period->start.tm_mday!=period->end.tm_mday);
        if (range) {
-               if(df[0]=='u') {
+               if (df=='u') {
                        i=strftime(text2, sizeof(text2)-i, "%Y %b %d", &period->end);
-               } else if(df[0]=='e') {
+               } else if (df=='e') {
                        i=strftime(text2, sizeof(text2)-i, "%d %b %Y", &period->end);
                } else {
                        i=strftime(text2, sizeof(text2)-i, "%Y.%U", &period->end);
@@ -1086,13 +1086,13 @@ int vrfydir(const struct periodstruct *per1, const char *addr, const char *site,
                wlen+=sprintf(wdir+wlen,"/%02d",d1);
                if(d1!=d2) wlen+=sprintf(wdir+wlen,"-%02d",d2);
        } else {
-               if(df[0] == 'u') {
+               if (df == 'u') {
                        wlen=snprintf(wdir+wlen,sizeof(wdir)-wlen,"%04d%s%02d-%04d%s%02d",y1,
                                conv_month_name(m1),d1,y2,conv_month_name(m2),d2);
-               } else if(df[0] == 'e') {
+               } else if (df == 'e') {
                        wlen=snprintf(wdir+wlen,sizeof(wdir)-wlen,"%02d%s%04d-%02d%s%04d",d1,
                                conv_month_name(m1),y1,d2,conv_month_name(m2),y2);
-               } else if(df[0] == 'w') {
+               } else if (df == 'w') {
                        wlen2=strftime(wdir+wlen, sizeof(wdir)-wlen, "%Y.%U", &per1->start);
                        if (wlen2==0) return(-1);
                        wlen+=wlen2;
@@ -1234,18 +1234,18 @@ void strip_latin(char *line)
        return;
 }
 
-void zdate(char *ftime,int ftimesize, const char *DateFormat)
+void zdate(char *ftime,int ftimesize, char DateFormat)
 {
        time_t t;
        struct tm *local;
 
        t = time(NULL);
        local = localtime(&t);
-       if(strcmp(DateFormat,"u") == 0)
+       if (DateFormat=='u')
                strftime(ftime, ftimesize, "%b/%d/%Y %H:%M", local);
-       if(strcmp(DateFormat,"e") == 0)
+       else if (DateFormat=='e')
                strftime(ftime, ftimesize, "%d/%b/%Y-%H:%M", local);
-       if(strcmp(DateFormat,"w") == 0)
+       else if (DateFormat=='w')
                strftime(ftime, ftimesize, "%W-%H-%M", local);
        return;
 }
@@ -1692,7 +1692,7 @@ void show_info(FILE *fp_ou)
        char ftime[127];
 
        if(!ShowSargInfo) return;
-       zdate(ftime, sizeof(ftime), DateFormat);
+       zdate(ftime, sizeof(ftime), df);
        fprintf(fp_ou,"<div class=\"info\">%s <a href='%s'>%s-%s</a> %s %s</div>\n",_("Generated by"),URL,PGM,VERSION,_("on"),ftime);
 }