
 Patch by Douglas E Toppin <dtoppin@patriot.net> to print
 long integers with commas, eg. "100,000" instead of "100000".

 
diff -ur gnuplot-3.7.orig/docs/gnuplot.doc gnuplot-3.7/docs/gnuplot.doc
--- gnuplot-3.7.orig/docs/gnuplot.doc	Tue Dec 22 19:43:00 1998
+++ gnuplot-3.7/docs/gnuplot.doc	Tue Jun  8 16:27:22 1999
@@ -3750,6 +3750,7 @@
        %S           scientific power
        %c           character replacement for scientific power
        %P           multiple of pi
+       %Q           integer with comma separators
 #\begin{tabular}{|cl|} \hline
 #\multicolumn{2}{|c|}{Tic-mark label numerical format specifiers}\\
 #\hline \hline
@@ -3814,6 +3815,7 @@
        set format y "%s %cg"; set ytic(12345)       # "12.345 kg"
        set format y "%.0P pi"; set ytic(6.283185)   # "2 pi"
        set format y "%.0P%%"; set ytic(50)          # "50%"
+       set format y "%Q                             # "100,000"
 
        set log y 2; set format y '%l'; set ytics (1,2,3)
        #displays "1.0", "1.0" and "1.5" (since 3 is 1.5 * 2^1)
diff -ur gnuplot-3.7.orig/graphics.c gnuplot-3.7/graphics.c
--- gnuplot-3.7.orig/graphics.c	Tue Jan 12 14:02:37 1999
+++ gnuplot-3.7/graphics.c	Tue Jun  8 16:26:52 1999
@@ -149,6 +149,7 @@
 				double *m, int *p));
 static void gprintf __PROTO((char *dest, size_t count, char *format,
 				double log_base, double x));
+static char *longcomma __PROTO((long value, char *dest_str));
 
 #if defined(sun386) || defined(AMIGA_SC_6_1)
 static double CheckLog __PROTO((TBOOLEAN is_log, double base_log, double x));
@@ -3953,6 +3954,54 @@
 }
 /*}}} */
 
+
+/*{{{ longcomma - output a long as a string with commas */
+static char *longcomma(value, dest_str)
+long value;			/* value of interest */
+char *dest_str;			/* string to put result in */
+{
+    char numstr[80];
+    char *str_pntr = dest_str;
+    int length;
+    int count = 0;
+    int rc;
+
+    if (value < 0)
+    {
+	*dest_str++ = '-';
+	count = 1;
+    }
+    
+    rc = sprintf(numstr, "%ld", value);
+    /*
+    	let's see if the number was bigger than the output buffer,
+    	if so, the stack may be hosed up but try to note
+    	the problem by putting a msg in the buffer and returning
+    */
+    if (rc >= sizeof(numstr))
+    {
+    	sprintf(numstr, "overflow");
+    	return(str_pntr);
+    }
+    
+    length = strlen(numstr) - 1;
+    
+    for (; count <= length; count++)
+    {
+	*dest_str++ = numstr[count];
+    
+	if (((length - count) % 3 == 0) && (count != length))
+	{
+	    *dest_str++ = ',';
+	}
+    }
+    
+    *dest_str = '\0';
+    return(str_pntr);
+}
+/*}}} */
+
+
 /*
  * Kludge alert!!
  * Workaround until we have a better solution ...
@@ -4002,7 +4051,18 @@
 
 	/*{{{  convert conversion character */
 	switch (*format) {
-	    /*{{{  x and o */
+	    /*{{{  Q */
+	case 'Q':		/* long with commas (eg. 100,000) */
+	    {
+		char commaBuf[80];
+		t[0] = *format++;
+		t[1] = 0;
+		longcomma(x, commaBuf);
+		strcpy(dest, commaBuf);
+		dest += strlen(dest);
+		break;
+	    }
+	    /*}}} */
 	case 'x':
 	case 'X':
 	case 'o':
