[rtems-schedsim commit] schedsim.c: Print basename of scenarion and verbose is on by default

Joel Sherrill joel at rtems.org
Tue May 27 13:58:43 UTC 2014


Module:    rtems-schedsim
Branch:    master
Commit:    01cb6c948724279c325206bda04896152c16a49b
Changeset: http://git.rtems.org/rtems-schedsim/commit/?id=01cb6c948724279c325206bda04896152c16a49b

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Tue May 27 09:06:47 2014 -0500

schedsim.c: Print basename of scenarion and verbose is on by default

---

 schedsim/shell/shared/schedsim.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/schedsim/shell/shared/schedsim.c b/schedsim/shell/shared/schedsim.c
index 532fb71..8f574bf 100644
--- a/schedsim/shell/shared/schedsim.c
+++ b/schedsim/shell/shared/schedsim.c
@@ -57,7 +57,6 @@ int ProcessScript(
   char              *argv[RTEMS_SHELL_MAXIMUM_ARGUMENTS];
   rtems_shell_cmd_t *shell_cmd;
   
- 
   while ( 1 ) {
     cStatus = fgets( buffer, sizeof(buffer), script );
     if ( cStatus == NULL )
@@ -79,7 +78,6 @@ int ProcessScript(
         break;
     }
 
-
     if (!strcmp(c,"bye") || !strcmp(c,"exit")) {
       exit( 0 );
     } 
@@ -111,14 +109,15 @@ int main(
   char **argv
 )
 {
-  int  sc;  
-  int  opt;
+  int         sc;  
+  int         opt;
+  const char *short_p;
 
   progname = argv[0];
   
   while ((opt = getopt(argc, argv, "v")) != -1) {
     switch (opt) {
-      case 'v': verbose = 0;                break;
+      case 'v': verbose = 0;  break;
       default: /* '?' */
         usage();
     }
@@ -132,13 +131,25 @@ int main(
 
   if ( !strcmp( scriptname, "-" ) ) {
     scriptname = "/dev/stdin";
+    short_p    = scriptname;
+  } else {
+    size_t  slen;
+
+    slen = strlen( scriptname );  /* Should not trust input but what's max? */
+    for ( ; slen > 0 ; slen-- ) {
+      if ( scriptname[slen] == '/' ) {
+        slen++;
+        break;
+      }
+    }
+    short_p = &scriptname[ slen ];
   }
 
   if ( verbose ) {
     printf(
       "Script File               : %s\n"
       "verbose                   : %d\n",
-      scriptname,
+      short_p,
       verbose
     );
   }




More information about the vc mailing list