You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2012/04/22 14:45:44 UTC

[lucy-commits] svn commit: r1328870 - in /lucy/trunk: charmonizer/src/Charmonizer/Core/ clownfish/src/ core/Lucy/Index/ core/Lucy/Object/ core/Lucy/Search/ core/Lucy/Test/ core/Lucy/Test/Object/ core/Lucy/Test/Util/ modules/unicode/utf8proc/ perl/xs/Lucy/Object/

Author: nwellnhof
Date: Sun Apr 22 12:45:43 2012
New Revision: 1328870

URL: http://svn.apache.org/viewvc?rev=1328870&view=rev
Log:
Const some strings to avoid g++ warnings

Modified:
    lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c
    lucy/trunk/clownfish/src/CFCPerl.c
    lucy/trunk/core/Lucy/Index/HighlightWriter.c
    lucy/trunk/core/Lucy/Object/Host.cfh
    lucy/trunk/core/Lucy/Search/QueryParser.c
    lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c
    lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c
    lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.cfh
    lucy/trunk/core/Lucy/Test/TestUtils.c
    lucy/trunk/core/Lucy/Test/TestUtils.cfh
    lucy/trunk/core/Lucy/Test/Util/TestJson.c
    lucy/trunk/modules/unicode/utf8proc/utf8proc.c
    lucy/trunk/perl/xs/Lucy/Object/Host.c

Modified: lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c
URL: http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c Sun Apr 22 12:45:43 2012
@@ -169,7 +169,7 @@ OS_run_quietly(const char *command) {
 void
 OS_mkdir(const char *filepath) {
     #if (defined(SHELL_IS_POSIX) || defined (SHELL_IS_CMD_EXE))
-    char *mkdir_command = "mkdir";
+    const char *mkdir_command = "mkdir";
     #endif
     unsigned size = strlen(mkdir_command) + 1 + strlen(filepath) + 1;
     char *command = (char*)malloc(size);
@@ -181,9 +181,9 @@ OS_mkdir(const char *filepath) {
 void
 OS_rmdir(const char *filepath) {
     #ifdef SHELL_IS_POSIX
-    char *rmdir_command = "rmdir";
+    const char *rmdir_command = "rmdir";
     #elif defined(SHELL_IS_CMD_EXE)
-    char *rmdir_command = "rmdir /q";
+    const char *rmdir_command = "rmdir /q";
     #endif
     unsigned size = strlen(rmdir_command) + 1 + strlen(filepath) + 1;
     char *command = (char*)malloc(size);

Modified: lucy/trunk/clownfish/src/CFCPerl.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/src/CFCPerl.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/clownfish/src/CFCPerl.c (original)
+++ lucy/trunk/clownfish/src/CFCPerl.c Sun Apr 22 12:45:43 2012
@@ -384,7 +384,7 @@ S_xs_file_contents(CFCPerl *self, const 
     "_init_autobindings()\n"
     "PPCODE:\n"
     "{\n"
-    "    char* file = __FILE__;\n"
+    "    const char* file = __FILE__;\n"
     "    CHY_UNUSED_VAR(cv);\n"
     "    CHY_UNUSED_VAR(items); %s\n"
     "}\n"

Modified: lucy/trunk/core/Lucy/Index/HighlightWriter.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Index/HighlightWriter.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Index/HighlightWriter.c (original)
+++ lucy/trunk/core/Lucy/Index/HighlightWriter.c Sun Apr 22 12:45:43 2012
@@ -136,7 +136,7 @@ HLWriter_add_inverted_doc(HighlightWrite
 
 ByteBuf*
 HLWriter_tv_buf(HighlightWriter *self, Inversion *inversion) {
-    char       *last_text = "";
+    const char *last_text = "";
     size_t      last_len = 0;
     ByteBuf    *tv_buf = BB_new(20 + Inversion_Get_Size(inversion) * 8);
     uint32_t    num_postings = 0;

Modified: lucy/trunk/core/Lucy/Object/Host.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/Host.cfh?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/Host.cfh (original)
+++ lucy/trunk/core/Lucy/Object/Host.cfh Sun Apr 22 12:45:43 2012
@@ -71,18 +71,18 @@ inert class Lucy::Object::Host {
     /** Invoke an object method in a void context.
      */
     inert void
-    callback(void *self, char *method, uint32_t num_args, ...);
+    callback(void *self, const char *method, uint32_t num_args, ...);
 
     /** Invoke an object method, expecting an integer.
      */
     inert int64_t
-    callback_i64(void *self, char *method, uint32_t num_args, ...);
+    callback_i64(void *self, const char *method, uint32_t num_args, ...);
 
     /** Invoke an object method, expecting a 64-bit floating point return
      * value.
      */
     inert double
-    callback_f64(void *self, char *method, uint32_t num_args, ...);
+    callback_f64(void *self, const char *method, uint32_t num_args, ...);
 
     /** Invoke an object method, expecting a Obj-derived object back, or
      * possibly NULL.  In order to ensure that the host environment doesn't
@@ -90,19 +90,19 @@ inert class Lucy::Object::Host {
      * caller will have to deal with.
      */
     inert incremented nullable Obj*
-    callback_obj(void *self, char *method, uint32_t num_args, ...);
+    callback_obj(void *self, const char *method, uint32_t num_args, ...);
 
     /** Invoke an object method, expecting a host string of some kind back,
      * which will be converted into a newly allocated CharBuf.
      */
     inert incremented nullable CharBuf*
-    callback_str(void *self, char *method, uint32_t num_args, ...);
+    callback_str(void *self, const char *method, uint32_t num_args, ...);
 
     /** Invoke an object method, expecting a host data structure back.  It's
      * up to the caller to know how to process it.
      */
     inert nullable void*
-    callback_host(void *self, char *method, uint32_t num_args, ...);
+    callback_host(void *self, const char *method, uint32_t num_args, ...);
 }
 
 

Modified: lucy/trunk/core/Lucy/Search/QueryParser.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Search/QueryParser.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Search/QueryParser.c (original)
+++ lucy/trunk/core/Lucy/Search/QueryParser.c Sun Apr 22 12:45:43 2012
@@ -90,11 +90,11 @@ S_extract_paren_groups(QueryParser *self
 // matching is bordered on the right by either whitespace or the end of the
 // string.
 static bool_t
-S_consume_ascii_token(ViewCharBuf *qstring, char *ptr, size_t size);
+S_consume_ascii_token(ViewCharBuf *qstring, const char *ptr, size_t size);
 
 // Consume the supplied text if there's a match.
 static bool_t
-S_consume_ascii(ViewCharBuf *qstring, char *ptr, size_t size);
+S_consume_ascii(ViewCharBuf *qstring, const char *ptr, size_t size);
 
 // Consume what looks like a field name followed by a colon.
 static bool_t
@@ -736,7 +736,7 @@ QParser_prune(QueryParser *self, Query *
 }
 
 static bool_t
-S_consume_ascii(ViewCharBuf *qstring, char *ptr, size_t len) {
+S_consume_ascii(ViewCharBuf *qstring, const char *ptr, size_t len) {
     if (ViewCB_Starts_With_Str(qstring, ptr, len)) {
         ViewCB_Nip(qstring, len);
         return true;
@@ -745,7 +745,7 @@ S_consume_ascii(ViewCharBuf *qstring, ch
 }
 
 static bool_t
-S_consume_ascii_token(ViewCharBuf *qstring, char *ptr, size_t len) {
+S_consume_ascii_token(ViewCharBuf *qstring, const char *ptr, size_t len) {
     if (ViewCB_Starts_With_Str(qstring, ptr, len)) {
         if (len == ViewCB_Get_Size(qstring)
             || StrHelp_is_whitespace(ViewCB_Code_Point_At(qstring, len))

Modified: lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c (original)
+++ lucy/trunk/core/Lucy/Test/Object/TestCharBuf.c Sun Apr 22 12:45:43 2012
@@ -27,7 +27,7 @@ static char smiley[] = { (char)0xE2, (ch
 static uint32_t smiley_len = 3;
 
 static CharBuf*
-S_get_cb(char *string) {
+S_get_cb(const char *string) {
     return CB_new_from_utf8(string, strlen(string));
 }
 

Modified: lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c (original)
+++ lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.c Sun Apr 22 12:45:43 2012
@@ -24,7 +24,7 @@
 #include "Lucy/Object/LockFreeRegistry.h"
 
 StupidHashCharBuf*
-StupidHashCharBuf_new(char *text) {
+StupidHashCharBuf_new(const char *text) {
     return (StupidHashCharBuf*)CB_new_from_utf8(text, strlen(text));
 }
 

Modified: lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.cfh?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.cfh (original)
+++ lucy/trunk/core/Lucy/Test/Object/TestLockFreeRegistry.cfh Sun Apr 22 12:45:43 2012
@@ -25,7 +25,7 @@ inert class Lucy::Test::Object::TestLock
  */
 class Lucy::Test::Object::StupidHashCharBuf inherits Lucy::Object::CharBuf {
     inert incremented StupidHashCharBuf*
-    new(char *text);
+    new(const char *text);
 
     /** Always returns 1, guaranteeing collisions. */
     public int32_t

Modified: lucy/trunk/core/Lucy/Test/TestUtils.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Test/TestUtils.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Test/TestUtils.c (original)
+++ lucy/trunk/core/Lucy/Test/TestUtils.c Sun Apr 22 12:45:43 2012
@@ -232,7 +232,7 @@ TestUtils_freeze_thaw(Obj *object) {
 
 void
 TestUtils_test_analyzer(TestBatch *batch, Analyzer *analyzer, CharBuf *source,
-                        VArray *expected, char *message) {
+                        VArray *expected, const char *message) {
     Token *seed = Token_new((char*)CB_Get_Ptr8(source), CB_Get_Size(source),
                             0, 0, 1.0f, 1);
     Inversion *starter = Inversion_new(seed);

Modified: lucy/trunk/core/Lucy/Test/TestUtils.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Test/TestUtils.cfh?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Test/TestUtils.cfh (original)
+++ lucy/trunk/core/Lucy/Test/TestUtils.cfh Sun Apr 22 12:45:43 2012
@@ -112,7 +112,7 @@ inert class Lucy::Test::TestUtils  {
      */
     inert void
     test_analyzer(TestBatch *batch, Analyzer *analyzer, CharBuf *source,
-                  VArray *expected, char *message);
+                  VArray *expected, const char *message);
 }
 
 __C__

Modified: lucy/trunk/core/Lucy/Test/Util/TestJson.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Test/Util/TestJson.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Test/Util/TestJson.c (original)
+++ lucy/trunk/core/Lucy/Test/Util/TestJson.c Sun Apr 22 12:45:43 2012
@@ -45,7 +45,7 @@ test_tolerance(TestBatch *batch) {
 }
 
 // Test escapes for control characters ASCII 0-31.
-static char* control_escapes[] = {
+static const char* control_escapes[] = {
     "\\u0000",
     "\\u0001",
     "\\u0002",
@@ -82,7 +82,7 @@ static char* control_escapes[] = {
 };
 
 // Test quote and backslash escape in isolation, then in context.
-static char* quote_escapes_source[] = {
+static const char* quote_escapes_source[] = {
     "\"",
     "\\",
     "abc\"",
@@ -93,7 +93,7 @@ static char* quote_escapes_source[] = {
     "\"\\",
     NULL
 };
-static char* quote_escapes_json[] = {
+static const char* quote_escapes_json[] = {
     "\\\"",
     "\\\\",
     "abc\\\"",
@@ -113,9 +113,9 @@ test_escapes(TestBatch *batch) {
     for (int i = 0; control_escapes[i] != NULL; i++) {
         CB_Truncate(string, 0);
         CB_Cat_Char(string, i);
-        char    *escaped = control_escapes[i];
-        CharBuf *json    = Json_to_json((Obj*)string);
-        CharBuf *decoded = (CharBuf*)Json_from_json(json);
+        const char *escaped = control_escapes[i];
+        CharBuf    *json    = Json_to_json((Obj*)string);
+        CharBuf    *decoded = (CharBuf*)Json_from_json(json);
 
         CB_setf(json_wanted, "\"%s\"", escaped);
         CB_Trim(json);
@@ -130,8 +130,8 @@ test_escapes(TestBatch *batch) {
     }
 
     for (int i = 0; quote_escapes_source[i] != NULL; i++) {
-        char *source  = quote_escapes_source[i];
-        char *escaped = quote_escapes_json[i];
+        const char *source  = quote_escapes_source[i];
+        const char *escaped = quote_escapes_json[i];
         CB_setf(string, source, strlen(source));
         CharBuf *json    = Json_to_json((Obj*)string);
         CharBuf *decoded = (CharBuf*)Json_from_json(json);

Modified: lucy/trunk/modules/unicode/utf8proc/utf8proc.c
URL: http://svn.apache.org/viewvc/lucy/trunk/modules/unicode/utf8proc/utf8proc.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/modules/unicode/utf8proc/utf8proc.c (original)
+++ lucy/trunk/modules/unicode/utf8proc/utf8proc.c Sun Apr 22 12:45:43 2012
@@ -44,7 +44,7 @@
 
 #include <stdio.h>
 static void
-warn(char *string) {
+warn(const char *string) {
     fprintf(stderr, "ERROR: %s\n", string);
 }
 

Modified: lucy/trunk/perl/xs/Lucy/Object/Host.c
URL: http://svn.apache.org/viewvc/lucy/trunk/perl/xs/Lucy/Object/Host.c?rev=1328870&r1=1328869&r2=1328870&view=diff
==============================================================================
--- lucy/trunk/perl/xs/Lucy/Object/Host.c (original)
+++ lucy/trunk/perl/xs/Lucy/Object/Host.c Sun Apr 22 12:45:43 2012
@@ -25,7 +25,8 @@
 #include "Lucy/Util/Memory.h"
 
 static SV*
-S_do_callback_sv(void *vobj, char *method, uint32_t num_args, va_list args);
+S_do_callback_sv(void *vobj, const char *method, uint32_t num_args,
+                 va_list args);
 
 // Convert all arguments to Perl and place them on the Perl stack.
 static CHY_INLINE void
@@ -106,7 +107,7 @@ SI_push_args(void *vobj, va_list args, u
 }
 
 void
-lucy_Host_callback(void *vobj, char *method, uint32_t num_args, ...) {
+lucy_Host_callback(void *vobj, const char *method, uint32_t num_args, ...) {
     va_list args;
 
     va_start(args, num_args);
@@ -123,7 +124,7 @@ lucy_Host_callback(void *vobj, char *met
 }
 
 int64_t
-lucy_Host_callback_i64(void *vobj, char *method, uint32_t num_args, ...) {
+lucy_Host_callback_i64(void *vobj, const char *method, uint32_t num_args, ...) {
     va_list args;
     SV *return_sv;
     int64_t retval;
@@ -153,7 +154,7 @@ lucy_Host_callback_i64(void *vobj, char 
 }
 
 double
-lucy_Host_callback_f64(void *vobj, char *method, uint32_t num_args, ...) {
+lucy_Host_callback_f64(void *vobj, const char *method, uint32_t num_args, ...) {
     va_list args;
     SV *return_sv;
     double retval;
@@ -170,7 +171,7 @@ lucy_Host_callback_f64(void *vobj, char 
 }
 
 lucy_Obj*
-lucy_Host_callback_obj(void *vobj, char *method, uint32_t num_args, ...) {
+lucy_Host_callback_obj(void *vobj, const char *method, uint32_t num_args, ...) {
     va_list args;
     SV *temp_retval;
     lucy_Obj *retval = NULL;
@@ -188,7 +189,7 @@ lucy_Host_callback_obj(void *vobj, char 
 }
 
 lucy_CharBuf*
-lucy_Host_callback_str(void *vobj, char *method, uint32_t num_args, ...) {
+lucy_Host_callback_str(void *vobj, const char *method, uint32_t num_args, ...) {
     va_list args;
     SV *temp_retval;
     lucy_CharBuf *retval = NULL;
@@ -211,7 +212,7 @@ lucy_Host_callback_str(void *vobj, char 
 }
 
 void*
-lucy_Host_callback_host(void *vobj, char *method, uint32_t num_args, ...) {
+lucy_Host_callback_host(void *vobj, const char *method, uint32_t num_args, ...) {
     va_list args;
     SV *retval;
 
@@ -227,7 +228,8 @@ lucy_Host_callback_host(void *vobj, char
 }
 
 static SV*
-S_do_callback_sv(void *vobj, char *method, uint32_t num_args, va_list args) {
+S_do_callback_sv(void *vobj, const char *method, uint32_t num_args,
+                 va_list args) {
     SV *return_val;
     SI_push_args(vobj, args, num_args);
     int num_returned = call_method(method, G_SCALAR);