Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

readdir: minor code cleanups

Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information...
commit bbc6bf3b0a5d48bf5a651e987605ce4e71a29943 1 parent 5f31686
@msteveb authored
Showing with 15 additions and 15 deletions.
  1. +15 −15 jim-readdir.c
View
30 jim-readdir.c
@@ -1,4 +1,3 @@
-
/*
* Tcl readdir command.
*
@@ -92,24 +91,25 @@ int Jim_ReaddirCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Jim_SetResultString(interp, strerror(errno), -1);
return JIM_ERR;
}
- Jim_SetResultString(interp, strerror(errno), -1);
-
- Jim_SetResult(interp, Jim_NewListObj(interp, NULL, 0));
+ else {
+ Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
- while ((entryPtr = readdir(dirPtr)) != NULL) {
- if (entryPtr->d_name[0] == '.') {
- if (entryPtr->d_name[1] == '\0') {
- continue;
+ while ((entryPtr = readdir(dirPtr)) != NULL) {
+ if (entryPtr->d_name[0] == '.') {
+ if (entryPtr->d_name[1] == '\0') {
+ continue;
+ }
+ if ((entryPtr->d_name[1] == '.') && (entryPtr->d_name[2] == '\0'))
+ continue;
}
- if ((entryPtr->d_name[1] == '.') && (entryPtr->d_name[2] == '\0'))
- continue;
+ Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, entryPtr->d_name, -1));
}
- Jim_ListAppendElement(interp, Jim_GetResult(interp), Jim_NewStringObj(interp,
- entryPtr->d_name, -1));
- }
- closedir(dirPtr);
+ closedir(dirPtr);
- return JIM_OK;
+ Jim_SetResult(interp, listObj);
+
+ return JIM_OK;
+ }
}
int Jim_readdirInit(Jim_Interp *interp)
Please sign in to comment.
Something went wrong with that request. Please try again.