ibp (0.21-7) ibp.c

Summary

 ibp.c |   44 ++++++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 14 deletions(-)

    
download this patch

Patch contents

--- ibp-0.21.orig/ibp.c
+++ ibp-0.21/ibp.c
@@ -133,8 +133,8 @@
    }
    attron(A_REVERSE); 
    move(21,0); 
-   if (multiband) addstr(" Keys:   1...5: select band   M: toggle multi-band                     Q: quit "); 
-   else addstr(" Keys:  1..5: select band  M: toggle multi-band  C: toggle morse code  Q: quit "); 
+   if (multiband) addstr(" Keys:   1...5: select band   m: toggle multi-band                     q: quit "); 
+   else addstr(" Keys:  1..5: select band  m: toggle multi-band  c: toggle morse code  q: quit "); 
    attroff(A_REVERSE);
 
    for(;;) {
@@ -263,13 +263,22 @@
 int is_locator(char *s)
 /* returns 1 if and only if s looks like a Maidenhead locator */
 {
-   if (!isalpha(s[0])) return 0;
-   if (!isalpha(s[1])) return 0;
-   if (!isdigit(s[2])) return 0;
-   if (!isdigit(s[3])) return 0;
-   if (!isalpha(s[4])) return 0;
-   if (!isalpha(s[5])) return 0;
-   if (isgraph(s[6])) return 0;
+   if (strlen(s) == 6) {
+      if (!isalpha(s[0])) return 0;
+      if (!isalpha(s[1])) return 0;
+      if (!isdigit(s[2])) return 0;
+      if (!isdigit(s[3])) return 0;
+      if (!isalpha(s[4])) return 0;
+      if (!isalpha(s[5])) return 0;
+      if (isgraph(s[6])) return 0;
+   }
+   else if (strlen(s) == 4) {
+      if (!isalpha(s[0])) return 0;
+      if (!isalpha(s[1])) return 0;
+      if (!isdigit(s[2])) return 0;
+      if (!isdigit(s[3])) return 0;
+      if (isgraph(s[4])) return 0;
+   }
    return 1;
 }
 
@@ -353,9 +362,18 @@
          } else if (is_locator(argv[argc])) {
             if (myloc_ok) err=1;
             else {
-               strncpy(mylocator,argv[argc],6);
-               mylocator[6]=0;
-               myloc_ok=1;
+               if (strlen(argv[argc])==6) {
+                  strncpy(mylocator,argv[argc],6);
+                  mylocator[6]=0;
+                  myloc_ok=1;
+               }
+               if (strlen(argv[argc])==4) {
+                  strncpy(mylocator,argv[argc],4);
+                  mylocator[4]='a';
+                  mylocator[5]='a';
+                  mylocator[6]=0;
+                  myloc_ok=1;
+               }
             }
          } else {
             err=1;
@@ -373,9 +391,7 @@
              "-c or --nocolour: don't use colour, even on a colour terminal.\n"
              "-m or --morse:    display callsign of active beacon in morse code (not in\n"
              "                  multi-band mode).\n"
-#ifndef noX11
              "-x or --nograph:  don't open the X11 graphic window, even if DISPLAY is set.\n"
-#endif
              "a band expressed either in MHz (14, 18, 21, 24 or 28) or in meters (20, 17, 15,\n"
              "    12 or 10); if no band is specified, the program starts in multi-band mode.\n"
              "a Maidenhead locator (like JO32KF), to be used for the calculation of distance\n"