[Groonga-commit] groonga/groonga [master] Fixed missing fgets error handling.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 6月 23日 (水) 14:57:21 JST


Daijiro MORI	2010-06-23 05:57:21 +0000 (Wed, 23 Jun 2010)

  New Revision: 1fd9b02f0a69ddab771b24b9bc579c57222014f9

  Log:
    Fixed missing fgets error handling.

  Modified files:
    src/groonga.c

  Modified: src/groonga.c (+14 -5)
===================================================================
--- src/groonga.c    2010-06-23 05:41:38 +0000 (5ea51d1)
+++ src/groonga.c    2010-06-23 05:57:21 +0000 (c18cba7)
@@ -166,19 +166,25 @@ prompt(char *buf)
     es = el_gets(el, &len);
     if (len > 0 && BUFSIZE > len) {
       history(elh, &elhv, H_ENTER, es);
-      strncpy(buf,es,len);
+      strncpy(buf, es, len);
     } else {
       buf = "";
       len = 0;
     }
 #else
     fprintf(stderr, "> ");
-    fgets(buf, BUFSIZE, stdin);
-    len = strlen(buf);
+    if (fgets(buf, BUFSIZE, stdin)) {
+      len = strlen(buf);
+    } else {
+      len = 0;
+    }
 #endif
   } else {
-    fgets(buf, BUFSIZE, stdin);
-    len = strlen(buf);
+    if (fgets(buf, BUFSIZE, stdin)) {
+      len = strlen(buf);
+    } else {
+      len = 0;
+    }
   }
   return len;
 }
@@ -378,6 +384,9 @@ print_return_code(grn_ctx *ctx, grn_rc rc, grn_obj *head, grn_obj *body, grn_obj
     }
     GRN_TEXT_PUTS(ctx, foot, "</RESULT>");
     break;
+  case GRN_CONTENT_MSGPACK:
+    // todo
+    break;
   case GRN_CONTENT_NONE:
     break;
   }




Groonga-commit メーリングリストの案内
Back to archive index