]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - sort.c
Optimize away a useless strcpy.
[thirdparty/sarg.git] / sort.c
diff --git a/sort.c b/sort.c
index 47e95d25e4c9ae6c12787d1f9b2a91804e189eab..f2802d438191080e4fc3e14d4b6dcb4070ad05f4 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -1,6 +1,6 @@
 /*
  * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
- *                                                            1998, 2012
+ *                                                            1998, 2015
  *
  * SARG donations:
  *      please look at http://sarg.sourceforge.net/donations.php
@@ -63,30 +63,32 @@ void tmpsort(const struct userinfostruct *uinfo)
                order="-r";
 
        if (snprintf(arqin,sizeof(arqin),"%s/%s.utmp",tmp,uinfo->filename)>=sizeof(arqin)) {
-               debuga(_("file name too long: %s/%s.utmp\n"),tmp,uinfo->filename);
+               debuga(__FILE__,__LINE__,_("Path too long: "));
+               debuga_more("%s/%s.utmp\n",tmp,uinfo->filename);
                exit(EXIT_FAILURE);
        }
        if (snprintf(arqou,sizeof(arqou),"%s/htmlrel.txt",tmp)>=sizeof(arqou)) {
-               debuga(_("file name too long: %s/htmlrel.txt\n"),tmp);
+               debuga(__FILE__,__LINE__,_("Path too long: "));
+               debuga_more("%s/htmlrel.txt\n",tmp);
                exit(EXIT_FAILURE);
        }
 
        if(debug) {
-               debuga(_("Sorting file: %s\n"),arqin);
+               debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),arqin);
        }
 
        if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin)>=sizeof(csort)) {
-               debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),arqin,arqou);
+               debuga(__FILE__,__LINE__,_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),arqin,arqou);
                exit(EXIT_FAILURE);
        }
        cstatus=system(csort);
        if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
-               debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
-               debuga(_("sort command: %s\n"),csort);
+               debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+               debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
        if (!KeepTempLog && unlink(arqin)) {
-               debuga(_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -115,28 +117,33 @@ void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo)
        int clen;
 
        if(debug) {
-               debuga(_("Sorting log %s/%s.user_unsort\n"),tmp,uinfo->filename);
+               snprintf(csort,sizeof(csort),"%s/%s.user_unsort",tmp,uinfo->filename);
+               debuga(__FILE__,__LINE__,_("Sorting file \"%s\"\n"),csort);
        }
 
        user=uinfo->filename;
        clen=snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" -k 4,4 -k 1,1 -k 2,2 -o \"%s/%s.user_log\" \"%s/%s.user_unsort\"",
                        tmp, tmp, user, tmp, user);
        if (clen>=sizeof(csort)) {
-               debuga(_("user name too long to sort %s\n"),csort);
+               /* TRANSLATORS: The message is followed by the command that is too long. */
+               debuga(__FILE__,__LINE__,_("User name too long to sort with command "));
+               debuga_more("sort -T \"%s\" -t \"\t\" -k 4,4 -k 1,1 -k 2,2 -o \"%s/%s.user_log\" \"%s/%s.user_unsort\"",
+                                       tmp, tmp, user, tmp, user);
                exit(EXIT_FAILURE);
        }
        cstatus=system(csort);
        if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
-               debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
-               debuga(_("sort command: %s\n"),csort);
+               debuga(__FILE__,__LINE__,_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+               debuga(__FILE__,__LINE__,_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
        if (snprintf(csort,sizeof(csort),"%s/%s.user_unsort",tmp,user)>=sizeof(csort)) {
-               debuga(_("user name too long for %s/%s.user_unsort\n"),tmp,user);
+               debuga(__FILE__,__LINE__,_("User name too long to manufacture file name "));
+               debuga_more("%s/%s.user_unsort\n",tmp,user);
                exit(EXIT_FAILURE);
        }
        if (!KeepTempLog && unlink(csort)) {
-               debuga(_("Cannot delete \"%s\": %s\n"),csort,strerror(errno));
+               debuga(__FILE__,__LINE__,_("Cannot delete \"%s\": %s\n"),csort,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -157,7 +164,7 @@ void sort_labels(const char **label,const char **order)
        } else if((UserSort & USER_SORT_SITE) != 0) {
                *label=_("site");
        } else if((UserSort & USER_SORT_TIME) != 0) {
-               *label=_("time");
+               *label=pgettext("duration","time");
        } else {
                *label=_("bytes");
        }