Bug#755269: [Debian-Islamic-maintainers] Bug#755269: you want %lc instead of %c

2014-10-30 Thread أحمد المحمودي
On Thu, Oct 30, 2014 at 06:27:09AM +0100, Adam Borowski wrote:
 Just replace %c with %lc, it will do the right thing both in ISO-8859-1 and
 in Unicode locales.  Not sure about other ancient charsets, but I can't
 think of any reason to support them (including ISO-8859-1 for that matter)
 in 2014 anymore.
 
 0xB0 is ° in both ISO-8859-1 and in Unicode.
---end quoted text---

  Tried that, but it made the output worse.

  Additionally I tried adding wchar.h to includes and declaraing 'symb' 
  as wchar_t. Yet got the same result. Here's the result of running 
  ipraytime after using %lc in the printf's:

Prayer schedule for,
 City : القاهرة
 Latitude : 030 Longitude: 031 Angle Method : Egyptian 
General Authority of Survey (Egypt)
 TimeZone : UTC+2.0
 Qibla: 137


  As you would notice, the long/lat minutes  seconds dissappeared, and so is 
the newline chars.
  Can't understand why this happened!

-- 
 ‎أحمد المحمودي (Ahmed El-Mahmoudy)
  Digital design engineer
 GPG KeyID: 0xEDDDA1B7
 GPG Fingerprint: 8206 A196 2084 7E6D 0DF8  B176 BC19 6A94 EDDD A1B7


signature.asc
Description: Digital signature


Bug#755269: [Debian-Islamic-maintainers] Bug#755269: you want %lc instead of %c

2014-10-30 Thread Adam Borowski
On Thu, Oct 30, 2014 at 09:31:33AM +0200, أحمد المحمودي wrote:
 On Thu, Oct 30, 2014 at 06:27:09AM +0100, Adam Borowski wrote:
  Just replace %c with %lc, it will do the right thing both in ISO-8859-1 and
  in Unicode locales.  Not sure about other ancient charsets, but I can't
  think of any reason to support them (including ISO-8859-1 for that matter)
  in 2014 anymore.
  
  0xB0 is ° in both ISO-8859-1 and in Unicode.
 ---end quoted text---
 
   Tried that, but it made the output worse.

Ah I see, the call to setlocale() was missing.

So here's a patch, this time tested ☺

-- 
// If you believe in so-called intellectual property, please immediately
// cease using counterfeit alphabets.  Instead, contact the nearest temple
// of Amon, whose priests will provide you with scribal services for all
// your writing needs, for Reasonable and Non-Discriminatory prices.
diff -Nurd itools-1.0.orig/ipraytime.c itools-1.0/ipraytime.c
--- itools-1.0.orig/ipraytime.c	2009-07-06 22:41:13.0 +0200
+++ itools-1.0/ipraytime.c	2014-10-30 16:58:13.301433287 +0100
@@ -30,6 +30,7 @@
 #include string.h /* for strlen/strcat/etc */
 #include unistd.h /* for getuid */
 #include pwd.h/* for getpwuid */
+#include locale.h /* for setlocale */
 
 /* For time_t */
 #ifdef TM_IN_SYS_TIME
@@ -460,7 +461,7 @@
 
int deg, min;
double sec;
-   const char symb = (char)0xB0;
+   const wchar_t symb = 0xB0;
 
printf(\n);
printf(Prayer schedule for,\n);
@@ -470,11 +471,11 @@
   printf( City : %s\n, city_name);
 
decimal2Dms(loc-degreeLat, deg, min, sec);
-   printf( Latitude : %03d%c %02d\' %02d\ %c\n, abs(deg), symb,
+   printf( Latitude : %03d%lc %02d\' %02d\ %c\n, abs(deg), symb,
   abs(min), abs(sec), (loc-degreeLat =0 ? 'N' : 'S'));
 
decimal2Dms(loc-degreeLong, deg, min, sec);
-   printf( Longitude: %03d%c %02d\' %02d\ %c\n, abs(deg), symb,
+   printf( Longitude: %03d%lc %02d\' %02d\ %c\n, abs(deg), symb,
   abs(min), abs(sec), (loc-degreeLong =0 ? 'E' : 'W'));
 
printf( Angle Method : %s\n, method_name);
@@ -485,7 +486,7 @@
/* Deal with Qibla Information */
qibla= getNorthQibla(loc);
decimal2Dms (qibla, deg, min, sec);
-   printf( Qibla: %03d%c %02d\' %02d\ %c of true North\n,
+   printf( Qibla: %03d%lc %02d\' %02d\ %c of true North\n,
   abs (deg), symb, abs (min), abs (sec), (qibla =0 ? 'W' : 'E'));
 
printf(\n);
@@ -645,6 +646,8 @@
Date dst_end;
sPrefuser_input;
 
+   setlocale(LC_CTYPE, );
+
/* Read-in the init RC file */
do_init_file(user_input, loc, date);