[Groonga-commit] groonga/groonga at 720ed2e [master] grn_ts: remove an old comment

アーカイブの一覧に戻る

susumu.yata null+****@clear*****
Tue Sep 15 09:20:44 JST 2015


susumu.yata	2015-09-15 09:20:44 +0900 (Tue, 15 Sep 2015)

  New Revision: 720ed2e326a254c699333b1b61816a4487792cac
  https://github.com/groonga/groonga/commit/720ed2e326a254c699333b1b61816a4487792cac

  Message:
    grn_ts: remove an old comment

  Modified files:
    lib/ts.c

  Modified: lib/ts.c (+0 -133)
===================================================================
--- lib/ts.c    2015-09-15 09:19:21 +0900 (8751d6f)
+++ lib/ts.c    2015-09-15 09:20:44 +0900 (b61428f)
@@ -3531,139 +3531,6 @@ grn_ts_expr_parser_close(grn_ctx *ctx, grn_ts_expr_parser *parser) {
   GRN_FREE(parser);
 }
 
-#if 0
-/* grn_ts_expr_parser_detect_number() detects an Int or Float. */
-// FIXME
-static grn_rc
-grn_ts_expr_parser_detect_number(grn_ctx *ctx, grn_ts_expr_parser *parser,
-                                 grn_ts_str str, size_t *token_size) {
-  grn_rc rc;
-  grn_ts_buf buf;
-  grn_ts_buf_init(ctx, &buf);
-  rc = grn_ts_buf_resize(ctx, &buf, str.size + 1);
-  if (rc == GRN_SUCCESS) {
-    char *end, *ptr = (char *)buf.ptr;
-    grn_memcpy(ptr, str.ptr, str.size);
-    ptr[str.size] = '\0';
-    strtol(ptr, &end, 0);
-    if ((end == ptr) || (*end == '.')) {
-      strtod(ptr, &end);
-      if (end == ptr) {
-        rc = GRN_INVALID_ARGUMENT;
-      }
-    }
-    if (rc == GRN_SUCCESS) {
-      *token_size = end - ptr;
-    }
-  }
-  grn_ts_buf_fin(ctx, &buf);
-  return rc;
-}
-
-static grn_rc
-grn_ts_expr_parser_push(grn_ctx *ctx, grn_ts_expr_parser *parser,
-                        grn_ts_expr *expr, grn_ts_str str) {
-  if ((str.size == GRN_COLUMN_NAME_ID_LEN) &&
-      !memcmp(str.ptr, GRN_COLUMN_NAME_ID, GRN_COLUMN_NAME_ID_LEN)) {
-    return grn_ts_expr_push_id(ctx, expr);
-  } else if ((str.size == GRN_COLUMN_NAME_KEY_LEN) &&
-             !memcmp(str.ptr, GRN_COLUMN_NAME_KEY, GRN_COLUMN_NAME_KEY_LEN)) {
-    return grn_ts_expr_push_key(ctx, expr);
-  } else if ((str.size == GRN_COLUMN_NAME_VALUE_LEN) &&
-             !memcmp(str.ptr, GRN_COLUMN_NAME_VALUE,
-                     GRN_COLUMN_NAME_VALUE_LEN)) {
-    return grn_ts_expr_push_value(ctx, expr);
-  } else if ((str.size == GRN_COLUMN_NAME_SCORE_LEN) &&
-             !memcmp(str.ptr, GRN_COLUMN_NAME_SCORE,
-                     GRN_COLUMN_NAME_SCORE_LEN)) {
-    return grn_ts_expr_push_score(ctx, expr);
-  } else if ((str.size == 4) && !memcmp(str.ptr, "true", 4)) {
-    return grn_ts_expr_push_bool(ctx, expr, GRN_TRUE);
-  } else if ((str.size == 5) && !memcmp(str.ptr, "false", 5)) {
-    return grn_ts_expr_push_bool(ctx, expr, GRN_FALSE);
-  } else if (isdigit((unsigned char)str.ptr[0])) {
-    /* Push a number (Int or Float). */
-    char *buf, *end;
-    grn_rc rc;
-    grn_ts_int int_value;
-    buf = GRN_MALLOCN(char, str.size + 1);
-    if (!buf) {
-      return GRN_NO_MEMORY_AVAILABLE;
-    }
-    grn_memcpy(buf, str.ptr, str.size);
-    buf[str.size] = '\0';
-    // FIXME: strtol() converts a string to a long integer, not int64_t.
-    int_value = strtol(buf, &end, 0);
-    if (*end == '\0') {
-      rc = grn_ts_expr_push_int(ctx, expr, int_value);
-    } else if (*end == '.') {
-      grn_ts_float float_value = strtod(buf, &end);
-      if (*end == '\0') {
-        rc = grn_ts_expr_push_float(ctx, expr, float_value);
-      } else {
-        rc = GRN_INVALID_ARGUMENT;
-      }
-    }
-    GRN_FREE(buf);
-    return rc;
-  } else if (str.ptr[0] == '"') {
-    /* Push a Text. */
-    char *buf;
-    size_t i, len, end;
-    grn_rc rc;
-    if (str.ptr[str.size - 1] != '"') {
-      return GRN_INVALID_ARGUMENT;
-    }
-    if (str.size == 2) {
-      return grn_ts_expr_push_text(ctx, expr, grn_ts_text_zero());
-    }
-    buf = GRN_MALLOCN(char, str.size - 2);
-    if (!buf) {
-      return GRN_NO_MEMORY_AVAILABLE;
-    }
-    rc = GRN_SUCCESS;
-    len = 0;
-    end = str.size - 1;
-    for (i = 1; (rc == GRN_SUCCESS) && (i < end); i++) {
-      switch (str.ptr[i]) {
-        case '\\': {
-          if (i == (end - 1)) {
-            rc = GRN_INVALID_ARGUMENT;
-            break;
-          }
-          buf[len++] = str.ptr[++i];
-          break;
-        }
-        case '"': {
-          rc = GRN_INVALID_ARGUMENT;
-          break;
-        }
-        default: {
-          buf[len++] = str.ptr[i];
-          break;
-        }
-      }
-    }
-    if (rc == GRN_SUCCESS) {
-      grn_ts_text value = { buf, len };
-      rc = grn_ts_expr_push_text(ctx, expr, value);
-    }
-    GRN_FREE(buf);
-    return rc;
-  } else {
-    /* Push a column. */
-    grn_rc rc;
-    grn_obj *column = grn_obj_column(ctx, expr->curr_table, str.ptr, str.size);
-    if (!column) {
-      return GRN_INVALID_ARGUMENT;
-    }
-    rc = grn_ts_expr_push_column(ctx, expr, column);
-    grn_obj_unlink(ctx, column);
-    return rc;
-  }
-}
-#endif
-
 /* grn_ts_expr_parser_tokenize_number() extracts the next token. */
 static grn_rc
 grn_ts_expr_parser_tokenize_number(grn_ctx *ctx, grn_ts_expr_parser *parser,
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る