[Ocfs2-tools-commits] smushran commits r507 - in
trunk/debugfs.ocfs2: . include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Dec 22 16:08:15 CST 2004
Author: smushran
Date: 2004-12-22 16:08:13 -0600 (Wed, 22 Dec 2004)
New Revision: 507
Modified:
trunk/debugfs.ocfs2/commands.c
trunk/debugfs.ocfs2/include/utils.h
trunk/debugfs.ocfs2/main.c
trunk/debugfs.ocfs2/utils.c
Log:
debugfs now handles user inputs containing extra whitespaces
Modified: trunk/debugfs.ocfs2/commands.c
===================================================================
--- trunk/debugfs.ocfs2/commands.c 2004-12-22 19:00:45 UTC (rev 506)
+++ trunk/debugfs.ocfs2/commands.c 2004-12-22 22:08:13 UTC (rev 507)
@@ -133,6 +133,9 @@
args = g_strsplit (cmd, " ", -1);
+ /* Move empty strings to the end */
+ crunch_strsplit(args);
+
command = find_command (args[0]);
if (command)
Modified: trunk/debugfs.ocfs2/include/utils.h
===================================================================
--- trunk/debugfs.ocfs2/include/utils.h 2004-12-22 19:00:45 UTC (rev 506)
+++ trunk/debugfs.ocfs2/include/utils.h 2004-12-22 22:08:13 UTC (rev 507)
@@ -50,4 +50,5 @@
void inode_time_to_str(uint64_t mtime, char *str, int len);
errcode_t rdump_inode(ocfs2_filesys *fs, uint64_t blkno, const char *name,
const char *dumproot, int verbose);
+void crunch_strsplit(char **args);
#endif /* __UTILS_H__ */
Modified: trunk/debugfs.ocfs2/main.c
===================================================================
--- trunk/debugfs.ocfs2/main.c 2004-12-22 19:00:45 UTC (rev 506)
+++ trunk/debugfs.ocfs2/main.c 2004-12-22 22:08:13 UTC (rev 507)
@@ -67,8 +67,10 @@
line = readline (PROMPT);
- if (line && *line)
+ if (line && *line) {
+ g_strchug(line);
add_history (line);
+ }
return line;
} /* get_line */
Modified: trunk/debugfs.ocfs2/utils.c
===================================================================
--- trunk/debugfs.ocfs2/utils.c 2004-12-22 19:00:45 UTC (rev 506)
+++ trunk/debugfs.ocfs2/utils.c 2004-12-22 22:08:13 UTC (rev 507)
@@ -681,3 +681,36 @@
return ret;
}
+
+/*
+ * crunch_strsplit()
+ *
+ * Moves empty strings to the end in args returned by g_strsplit(),
+ *
+ */
+void crunch_strsplit(char **args)
+{
+ char *p;
+ int i, j;
+
+ i = j = 0;
+ while(args[i]) {
+ if (!strlen(args[i])) {
+ j = max(j, i+1);
+ while(args[j]) {
+ if (strlen(args[j])) {
+ p = args[i];
+ args[i] = args[j];
+ args[j] = p;
+ break;
+ }
+ ++j;
+ }
+ if (!args[j])
+ break;
+ }
+ ++i;
+ }
+
+ return ;
+}
More information about the Ocfs2-tools-commits
mailing list