OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc_proc.c versions 1.30 and 1.31
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/rc/rc_proc.c 1.30 -> 1.31

--- rc_proc.c    2003/05/21 15:16:41     1.30
+++ rc_proc.c    2003/05/21 15:24:07     1.31
@@ -75,8 +75,8 @@
 rc_return_t procPopulate(rc_proc_t *pRc)
 {
     int nSect   = 0;
-    int nFdrc   = 0;
-    int nFdfunc = 0;
+    int nFdrc   = -1;
+    int nFdfunc = -1;
     int nRet    = 0;
     int nRc     = 0;
     ex_t Except;
@@ -89,23 +89,23 @@
     assert(*pRc->m_pAnal->m_szRcs);
     sBuf = (char *)calloc(1, RC_READ_BUFSIZE);
 
-    /* Open the func file if it exists in the configuration */
-    if (pRc->m_pAnal->m_szFuncs) {
-        if ((nFdfunc = open(pRc->m_pAnal->m_szFuncs, O_RDONLY)) < 0) {
-            RC_THROW(RC_ERR_FNC);
-        }
-    }
-
     /* Stick on the starting shell id line */
     scriptAppend(pRc->m_pScriptcom, "#! /bin/sh\n", strlen("#! /bin/sh\n"));
 
-    /* Read data from the func file */
-    while ((nRet = read(nFdfunc, sBuf, RC_READ_BUFSIZE)) > 0) {
-        scriptAppend(pRc->m_pScriptcom, sBuf, nRet);
+    /* Open the func file if it exists in the configuration */
+    if (pRc->m_pAnal->m_szFuncs) {
+        if ((nFdfunc = open(pRc->m_pAnal->m_szFuncs, O_RDONLY)) >= 0) {
+            /* Read data from the func file */
+            while ((nRet = read(nFdfunc, sBuf, RC_READ_BUFSIZE)) > 0) {
+                scriptAppend(pRc->m_pScriptcom, sBuf, nRet);
+            }
+            if (nRet == -1) /* Handle read errors */
+                RC_THROW(RC_ERR_IO);
+            scriptAppend(pRc->m_pScriptcom, "\n", sizeof(char));
+        }
+        else
+            RC_THROW(RC_ERR_FNC);
     }
-    scriptAppend(pRc->m_pScriptcom, "\n", sizeof(char));
-    if (nRet == -1) /* Handle read errors */
-        RC_THROW(RC_ERR_IO);
 
     /* Iteratively read possibly globbed rc files */
     for (nRc = 0; nRc < pRc->m_pAnal->m_nRcs; nRc++)

CVSTrac 2.0.1