factor: fix the mess
authorAlan Cox <alan@linux.intel.com>
Tue, 17 Mar 2015 12:10:38 +0000 (12:10 +0000)
committerAlan Cox <alan@linux.intel.com>
Tue, 17 Mar 2015 12:10:38 +0000 (12:10 +0000)
Grumble

Applications/util/factor.c

index fa11197..631f99a 100644 (file)
@@ -26,6 +26,7 @@ config FACTOR
 #include  <stdio.h>
 #include  <ctype.h>
 #include  <string.h>
+#include  <stdlib.h>
 
 static void factor(char *s)
 {
@@ -77,10 +78,12 @@ static void factor(char *s)
         l /= ll;
       }
     }
-    putc(stderr,'\n');
+    putc('\n', stderr);
   }
 }
 
+#define LINE_MAX 256
+
 int main(int argc,char *argv[])
 {
   if (argc > 1) {
@@ -88,10 +91,9 @@ int main(int argc,char *argv[])
 
     for (ss = argv; *ss; ss++) factor(*ss);
   } else for (;;) {
-    char *s = 0;
-    size_t len = 0;
+    char s[LINE_MAX];
 
-    if (-1 == gets_s(&s, LINE_MAX)) break;
+    if (NULL == gets_s(s, LINE_MAX)) break;
     factor(s);
   }
 }