bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch - debug X


From: Jim Cromie
Subject: patch - debug X
Date: Fri, 07 Nov 2003 15:58:21 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

hi Okuji etal,

attached are a few patches;

patch.debug: changes builtin-debug to take an optional numeric argument,
   and sets accordingly.  Argumentless form still toggles.

   ex:
      title foo
         debug 1
         debug 1   # still on
          debug      # now off
This should DWYW if your grub.confs already have 'debug 1'.
   doc-patch included.

patch.quit:
   I got annoyed at the error when I do grub> q <enter>,
   enough to try to fix it.
*However* it doesnt work (HUMPH). Im hoping its *trivial* to fix and include.
   no-doc patch - not much to say...

patch.chario:
I added grub_strchr(), grub_strpbrk() while trying to work out savedefault X.
   cursory tests (standalone) show them to work.. ymmv


Im new to patching grub, so Id prefer to send patches here (rather than the BTS website),
until I get some idea whats expected.

thx.
jimc
diff -ru grub-cvs/docs/grub.texi grub-cvs-mod/docs/grub.texi
--- grub-cvs/docs/grub.texi     Mon Jun  9 16:22:36 2003
+++ grub-cvs-mod/docs/grub.texi Fri Nov  7 14:06:58 2003
@@ -2490,9 +2490,13 @@
 @subsection debug
 
 @deffn Command debug
-Toggle debug mode (by default it is off). When debug mode is on, some
-extra messages are printed to show disk activity. This global debug flag
-is mainly useful for GRUB developers when testing new code.
+If given without an argument, toggles debug mode (by default it is off).
+If a numeric argument is given, debug mode is set accordingly to its
+truth value (ie: 0 is false).  When debug mode is on, some extra
+messages are printed to show disk activity.  This is effective only in
+the grub-shell, the boot-loader has no place to print messages.  This
+global debug flag is mainly useful for GRUB developers when testing new
+code.
 @end deffn
 
 
diff -ru grub-cvs/stage2/builtins.c grub-cvs-mod/stage2/builtins.c
--- grub-cvs/stage2/builtins.c  Sun Mar  9 18:12:26 2003
+++ grub-cvs-mod/stage2/builtins.c      Fri Nov  7 13:59:14 2003
@@ -731,17 +731,29 @@
 static int
 debug_func (char *arg, int flags)
 {
-  if (debug)
+  int dbgval = 0;
+  if (*arg)
     {
-      debug = 0;
-      grub_printf (" Debug mode is turned off\n");
+      /* use provided arg - dont just toggle */
+      if (safe_parse_maxint(&arg,&dbgval))
+       {
+         debug = dbgval;
+         grub_printf (" Debug mode is now %d\n", debug);
+       }
+      else grub_printf ("Warning: debug arg not understood: %s\n", arg);
     }
   else
-    {
-      debug = 1;
-      grub_printf (" Debug mode is turned on\n");
-    }
-
+    if (debug)
+      {
+       debug = 0;
+       grub_printf (" Debug mode is turned off\n");
+      }
+    else
+      {
+       debug = 1;
+       grub_printf (" Debug mode is turned on\n");
+      }
+  
   return 0;
 }
 
@@ -750,8 +762,9 @@
   "debug",
   debug_func,
   BUILTIN_CMDLINE,
-  "debug",
-  "Turn on/off the debug mode."
+  "debug [number]",
+  "If no arg provided, turn on/off (toggle) the debug mode."
+  "If numeric arg given, debug mode is set accordingly."
 };
 
 
@@ -1416,7 +1429,7 @@
   halt_func,
   BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
   "halt [--no-apm]",
-  "Halt your system. If APM is avaiable on it, turn off the power using"
+  "Halt your system. If APM is available on it, turn off the power using"
   " the APM BIOS, unless you specify the option `--no-apm'."
 };
 
Only in grub-cvs-mod/stage2: builtins.c.orig
--- grub-cvs/stage2/builtins.c  Sun Mar  9 18:12:26 2003
+++ grub-cvs.quit/stage2/builtins.c     Fri Nov  7 14:24:59 2003
@@ -2965,6 +2965,15 @@
   "quit",
   "Exit from the GRUB shell."
 };
+
+static struct builtin builtin_q =
+{
+  "q",
+  quit_func,
+  BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
+  "q",
+  "Exit from the GRUB shell."
+};
 #endif /* GRUB_UTIL */
 
 
@@ -4721,6 +4730,7 @@
   &builtin_pause,
 #ifdef GRUB_UTIL
   &builtin_quit,
+  &builtin_q,
 #endif /* GRUB_UTIL */
 #ifdef SUPPORT_NETBOOT
   &builtin_rarp,
--- grub-cvs/stage2/char_io.c   Sun Dec  8 23:27:05 2002
+++ grub-cvs.mod/stage2/char_io.c       Fri Nov  7 15:30:36 2003
@@ -1155,6 +1155,41 @@
   return 0;
 }
 
+char *
+grub_strchr (const char *s1, const int c)
+{
+  const char *ptr = s1;
+
+  while (*ptr && *ptr != (char) c)
+    ptr++;
+      
+  if (*ptr == (char) c)
+    return (char *) ptr;
+
+  return 0;
+}
+
+char *
+grub_strpbrk (const char *s1, const char *s2)
+{
+  while (*s1)
+    {
+      const char *ptr, *tmp;
+
+      ptr = s1;
+      tmp = s2;
+
+      while (*tmp && *ptr != *tmp)
+       tmp++;
+
+      if (*tmp) return (char *) ptr;
+      
+      s1++;
+    }
+
+  return 0;
+}
+
 int
 grub_strlen (const char *str)
 {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]