OSSP CVS Repository

ossp - Check-in [2455]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2455
Date: 2002-Aug-01 11:45:19 (local)
2002-Aug-01 09:45:19 (UTC)
User:ms
Branch:
Comment: Fix rcfile globbing.
Tickets:
Inspections:
Files:
ossp-pkg/rc/00TODO      1.32 -> 1.33     2 inserted, 0 deleted
ossp-pkg/rc/rc_anal.c      1.9 -> 1.10     10 inserted, 4 deleted

ossp-pkg/rc/00TODO 1.32 -> 1.33

--- 00TODO       2002/07/30 16:36:41     1.32
+++ 00TODO       2002/08/01 09:45:19     1.33
@@ -17,6 +17,8 @@
   Not efficient (reads whole files when only parts are needed...)
   What's going on with ^ in patterns? Something is broken.
   Resolve memory leaks with Dmalloc, ask for help.
+  Rc file prefix rc. is hardcoded, and when wildcard is given, the prefix is
+    used in selecting files. Location is not properly used. See rc_anal.c.
 
 Document
   Refs, pri, user, group, ci, go only in normal (not special) sections.


ossp-pkg/rc/rc_anal.c 1.9 -> 1.10

--- rc_anal.c    2002/08/01 08:55:05     1.9
+++ rc_anal.c    2002/08/01 09:45:19     1.10
@@ -64,6 +64,7 @@
     else { /* Only enter block with valid string, strdup can't handle NULL */
         (*ppInst)->m_szRcs = malloc(sizeof(char **));
         if (strcmp(kszName, RC_GLOB_WILD)) {
+            (*ppInst)->m_szRcs = malloc(sizeof(*((*ppInst)->m_szRcs)));
             *(*ppInst)->m_szRcs = strdup("rc."); /* FIXME: Remove hardcoded */
             strcat(*(*ppInst)->m_szRcs, kszName);
         }
@@ -184,8 +185,8 @@
 rc_return_t analGloblocs(rc_anal_t **ppInst)
 {
     struct dirent ***pppFiles = NULL;
-    int nIter  = 0;
-    int nCount = 0;
+    int nCount = 0; /* How many globbed files we find */
+    int nIter  = 0; /* Iterate over the number of globbed files */
 
     assert(*ppInst); /* Verify sanity */
 
@@ -193,11 +194,13 @@
     pppFiles = malloc(sizeof(struct dirent));
     nCount = scandir((*ppInst)->m_szLocs, pppFiles, analFileselect, alphasort);
 
-    /* Check out the health of this directory */
+    /* Check out the health of this directory listing */
     if (nCount == -1)
         return(RC_THROW(RC_ERR_DIR));
+    else /* Allocate for the string array to hold directory entry names */
+        (*ppInst)->m_szRcs = malloc(sizeof((*((*ppInst)->m_szRcs))) * (nCount + 1));
 
-    /* Loop through file index setting Rf file names according to dirent */
+    /* Loop through file index setting rc file names according to dirent */
     for (nIter = 0; nIter < nCount; ++nIter)
         (*ppInst)->m_szRcs[nIter] = strdup((*pppFiles)[nIter]->d_name);
     (*ppInst)->m_szRcs[nIter] = NULL;
@@ -239,6 +242,9 @@
 ************************************************/
 rc_return_t analDelete(rc_anal_t *pInst)
 {
+/* FIXME: It could be that pInst needs to be a double pointer to */
+/*        be properly used in destruction. Otherwise members are */
+/*        just copies of the stack parameters passed in.         */
     int nIter = 0;
 
     while (pInst->m_szRcs[nIter])   /* Rc file names       */

CVSTrac 2.0.1