]> git.eshelyaron.com Git - emacs.git/commitdiff
Mode line "%q" construct: Just use one number when both would be the same.
authorAlan Mackenzie <acm@muc.de>
Tue, 30 May 2017 17:42:52 +0000 (17:42 +0000)
committerAlan Mackenzie <acm@muc.de>
Tue, 30 May 2017 17:42:52 +0000 (17:42 +0000)
* src/xdisp (decode_mode_spec): recode the "%q" bit appropriately.

src/xdisp.c

index ddb26b8defd03be2cc2eeb421318e3b07a8ef6df..c03689bf6169a3cdfb3098c8a74c86ecadadfc21 100644 (file)
@@ -23992,21 +23992,18 @@ decode_mode_spec (struct window *w, register int c, int field_width,
         ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
         ptrdiff_t begv = BUF_BEGV (b);
         ptrdiff_t zv = BUF_ZV (b);
+        int top_perc, bot_perc;
 
         if ((toppos <= begv) && (zv <= botpos))
           return "All   ";
 
-        if (toppos <= begv)
-          strcpy (decode_mode_spec_buf, "0-");
-        else
-          sprintf (decode_mode_spec_buf, "%d-",
-                   percent99 (toppos - begv, zv - begv));
+        top_perc = toppos <= begv ? 0 : percent99 (toppos - begv, zv - begv);
+        bot_perc = zv <= botpos ? 100 : percent99 (botpos - begv, zv - begv);
 
-        if (zv <= botpos)
-          strcat (decode_mode_spec_buf, "100%");
+        if (top_perc == bot_perc)
+          sprintf (decode_mode_spec_buf, "%d%%", top_perc);
         else
-          sprintf (&decode_mode_spec_buf [strlen (decode_mode_spec_buf)],
-                   "%d%%", percent99 (botpos - begv, zv - begv));
+          sprintf (decode_mode_spec_buf, "%d-%d%%", top_perc, bot_perc);
 
         return decode_mode_spec_buf;
       }