1. Shlomi Fish
  2. fc-solve

Commits

Shlomi Fish  committed 9cf6fbd

More -ansi -pedantic fixes.

git-svn-id: file:///home/shlomif/Backup/svn-dumps/google-code/svnsync-repos/fc-solve/trunk@540 e7e8a897-7ba4-4ee7-b36f-f4c66519b19a

  • Participants
  • Parent commits 870fea8
  • Branches master

Comments (0)

Files changed (6)

File fc-solve/source/TODO

View file
 
     * Document the mapping of aliases -> test functions.
 
+    kpat:
+    -----
+
+    * Convert to the instance recycling.
+
 * Change char *'s to const char *'s in the API.
 
 * Compile with all the kdegames gcc flags and eliminate warnings.

File fc-solve/source/app_str.c

View file
 #include <stdarg.h>
 #include <stdlib.h>
 
-#define GROW_BY 4000
-
-struct freecell_solver_append_string_struct
-{
-    char * buffer;
-    char * end_of_buffer;
-    int max_size;
-    int size_of_margin;
-};
+#include "app_str.h"
 
-typedef struct freecell_solver_append_string_struct freecell_solver_append_string_t;
+#define GROW_BY 4000
 
 freecell_solver_append_string_t * freecell_solver_append_string_alloc(int size_margin)
 {

File fc-solve/source/cl_chop.c

View file
         }
         else if (*s == '\\')
         {
-            char next_char = *(++s);
+            next_char = *(++s);
             s++;
             if (next_char == '\0')
             {

File fc-solve/source/cmd_line.c

View file
             }
             {
                 int a;
-                const char * start_num;
-                const char * end_num;
+                char * start_num;
+                char * end_num;
                 char save;
-                start_num = argv[arg];
+                char * arg_copy;
+
+                arg_copy = strdup(argv[arg]);
+                start_num = arg_copy;
                 for(a=0;a<5;a++)
                 {
                     while ((*start_num > '9') && (*start_num < '0') && (*start_num != '\0'))
                     *end_num = save;
                     start_num=end_num+1;
                 }
+                free(arg_copy);
             }
         }
         else if ((!strcmp(argv[arg], "-opt")) || (!strcmp(argv[arg], "--optimize-solution")))
             (!strcmp(argv[arg], "--next-hard-thread"))
         )
         {
-            int ret;
             int is_st = ((!strcmp(argv[arg], "-nst")) || (!strcmp(argv[arg], "--next-soft-thread")));
 
             ret =
             }
             else
             {
-                int num_to_skip = 0;
-                char * s, * buffer;
+                int num_args_to_skip = 0;
+                char * buffer;
+                const char * s;
                 FILE * f;
                 long file_len;
-                int ret;
                 size_t num_read;
                 args_man_t * args_man;
 
                 }
                 if (*s == ',')
                 {
-                    num_to_skip = atoi(argv[arg]);
+                    num_args_to_skip = atoi(argv[arg]);
                     s++;
                 }
                 if (opened_files_dir)
                     return FCS_CMD_LINE_ERROR_IN_ARG;
                 }
 
-                if (num_to_skip >= args_man->argc)
+                if (num_args_to_skip >= args_man->argc)
                 {
                     /* Do nothing */
                 }
                 {
                     ret = freecell_solver_user_cmd_line_parse_args_with_file_nesting_count(
                         instance,
-                        args_man->argc - num_to_skip,
-                        args_man->argv + num_to_skip,
+                        args_man->argc - num_args_to_skip,
+                        (const char * *)(args_man->argv + num_args_to_skip),
                         0,
                         known_parameters,
                         callback,
                     ret = freecell_solver_user_cmd_line_parse_args_with_file_nesting_count(
                         instance,
                         preset_args->argc,
-                        preset_args->argv,
+                        (const char * *)(preset_args->argv),
                         0,
                         known_parameters,
                         callback,
 int freecell_solver_user_cmd_line_parse_args(
     void * instance,
     int argc,
-    char * argv[],
+    const char * argv[],
     int start_arg,
-    char * * known_parameters,
+    const char * * known_parameters,
     freecell_solver_user_cmd_line_known_commands_callback_t callback,
     void * callback_context,
     char * * error_string,

File fc-solve/source/fcs_user.h

View file
 
 extern void freecell_solver_user_set_soft_thread_name(
     void * user_instance,
-    char * name
+    const char * name
     );
 
 extern int freecell_solver_user_set_hard_thread_prelude(
     void * user_instance,
-    char * prelude
+    const char * prelude
     );
 
 extern void freecell_solver_user_recycle(

File fc-solve/source/lib.c

View file
 
 int freecell_solver_user_set_a_star_weight(
     void * user_instance,
-    int index,
+    int weight_index,
     double weight
     )
 {
 
     user = (fcs_user_t *)user_instance;
 
-    if ((index < 0) || (index >= (sizeof(user->soft_thread->a_star_weights)/sizeof(user->soft_thread->a_star_weights[0]))))
+    if ((weight_index < 0) || (weight_index >= (int)(sizeof(user->soft_thread->a_star_weights)/sizeof(user->soft_thread->a_star_weights[0]))))
     {
         return 1;
     }
         return 2;
     }
 
-    user->soft_thread->a_star_weights[index] = weight;
+    user->soft_thread->a_star_weights[weight_index] = weight;
 
     return 0;
 
 
     user = (fcs_user_t *)user_instance;
 
-    return
-        user->iter_handler(
-            user_instance,
-            iter_num,
-            depth,
-            (void *)ptr_state_with_locations,
-            parent_iter_num,
-            user->iter_handler_context
-            );
+    user->iter_handler(
+        user_instance,
+        iter_num,
+        depth,
+        (void *)ptr_state_with_locations,
+        parent_iter_num,
+        user->iter_handler_context
+        );
 }
 
 void freecell_solver_user_set_iter_handler(
 
 void freecell_solver_user_set_soft_thread_name(
     void * user_instance,
-    char * name
+    const char * name
     )
 {
     fcs_user_t * user;
 
 int freecell_solver_user_set_hard_thread_prelude(
     void * user_instance,
-    char * prelude
+    const char * prelude
     )
 {
     fcs_user_t * user;