]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2006-01-30 12:53:07 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Mon, 30 Jan 2006 12:53:08 +0000 (12:53 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Mon, 30 Jan 2006 12:53:08 +0000 (12:53 +0000)
replaced strncpy with strcpy where possible

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@631 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

cfg.c
evaluator.c

diff --git a/cfg.c b/cfg.c
index 66dbd98ed399d501a519b2b4410eef3a311a9ae9..f0e483a5b216375a9b88c68ef57e8c197a137f13 100644 (file)
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.47 2005/05/08 04:32:43 reinelt Exp $^
+/* $Id: cfg.c,v 1.48 2006/01/30 12:53:07 reinelt Exp $^
  *
  * config file stuff
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: cfg.c,v $
+ * Revision 1.48  2006/01/30 12:53:07  reinelt
+ * replaced strncpy with strcpy where possible
+ *
  * Revision 1.47  2005/05/08 04:32:43  reinelt
  * CodingStyle added and applied
  *
@@ -334,6 +337,7 @@ static char *strip(char *s, const int strip_comments)
 
     while (isblank(*s))
        s++;
+
     for (p = s; *p; p++) {
        if (*p == '"')
            do
@@ -348,8 +352,10 @@ static char *strip(char *s, const int strip_comments)
            break;
        }
     }
+
     for (p--; p > s && isblank(*p); p--)
        *p = '\0';
+
     return s;
 }
 
@@ -452,9 +458,9 @@ static void cfg_add(const char *section, const char *key, const char *val, const
 int cfg_cmd(const char *arg)
 {
     char *key, *val;
-    char buffer[256];
+    char *buffer;
 
-    strncpy(buffer, arg, sizeof(buffer));
+    buffer = strdup (arg);
     key = strip(buffer, 0);
     for (val = key; *val; val++) {
        if (*val == '=') {
@@ -462,11 +468,19 @@ int cfg_cmd(const char *arg)
            break;
        }
     }
-    if (*key == '\0' || *val == '\0')
+    if (*key == '\0' || *val == '\0') {
+       free (buffer);
        return -1;
-    if (!validchars(key))
+    }
+
+    if (!validchars(key)) {
+       free (buffer);
        return -1;
+    }
+
     cfg_add("", key, val, 1);
+
+    free (buffer);
     return 0;
 }
 
index 86235a1cd9ca714262f1928a125282133049012f..d22bbfa2449c7470119203cd08b8312a40f48753 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: evaluator.c,v 1.29 2006/01/30 06:11:36 reinelt Exp $
+/* $Id: evaluator.c,v 1.30 2006/01/30 12:53:08 reinelt Exp $
  *
  * expression evaluation
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: evaluator.c,v $
+ * Revision 1.30  2006/01/30 12:53:08  reinelt
+ * replaced strncpy with strcpy where possible
+ *
  * Revision 1.29  2006/01/30 06:11:36  reinelt
  * changed Result->length to Result->size
  *
@@ -377,10 +380,10 @@ RESULT *SetResult(RESULT ** result, const int type, const void *value)
            if ((*result)->string)
                free((*result)->string);
            /* allocate memory in multiples of CHUNK_SIZE */
-           (*result)->size = CHUNK_SIZE * (len / CHUNK_SIZE + 1);
+           (*result)->size = CHUNK_SIZE * ((len+1) / CHUNK_SIZE + 1);
            (*result)->string = malloc((*result)->size);
        }
-       strncpy((*result)->string, value, (*result)->size);
+       strcpy((*result)->string, value);
     } else {
        error("Evaluator: internal error: invalid result type %d", type);
        return NULL;
@@ -413,7 +416,7 @@ static RESULT *CopyResult(RESULT ** result, RESULT * value)
            (*result)->size = value->size;
            (*result)->string = malloc((*result)->size);
        }
-       strncpy((*result)->string, value->string, (*result)->size);
+       strcpy((*result)->string, value->string);
     }
     return *result;
 }
@@ -1315,7 +1318,7 @@ int Eval(void *tree, RESULT * result)
     if (result->size > 0) {
        result->string = malloc(result->size);
        if (Tree->Result->string != NULL) {
-           strncpy(result->string, Tree->Result->string, result->size);
+           strcpy(result->string, Tree->Result->string);
        } else
            result->string[0] = '\0';
     } else {