Browse Source

Install hint files into /usr/share/mc/hints instead of /usr/share/mc.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 14 years ago
parent
commit
280194ec15
4 changed files with 17 additions and 19 deletions
  1. 6 6
      doc/hints/Makefile.am
  2. 1 1
      lib/fileloc.h
  3. 8 11
      src/cmd.c
  4. 2 1
      src/help.c

+ 6 - 6
doc/hints/Makefile.am

@@ -1,11 +1,11 @@
-LIBFILES_OUT = mc.ext
-
-
-pkgdata_DATA = mc.hint mc.hint.cs mc.hint.es mc.hint.hu mc.hint.it	\
-	mc.hint.nl mc.hint.pl mc.hint.ru mc.hint.sr mc.hint.uk		\
+HINTFILES = \
+	mc.hint mc.hint.cs mc.hint.es mc.hint.hu mc.hint.it	\
+	mc.hint.nl mc.hint.pl mc.hint.ru mc.hint.sr mc.hint.uk	\
 	mc.hint.zh
 
+hintdir = $(pkgdatadir)/hints
+hint_DATA = $(HINTFILES)
 
 # Files processed by configure don't need to be here
 EXTRA_DIST = \
-	$(pkgdata_DATA)
+	$(HINTFILES)

+ 1 - 1
lib/fileloc.h

@@ -24,7 +24,7 @@
 #define MC_GLOBAL_CONFIG_FILE	"mc.lib"
 #define MC_GLOBAL_MENU		"mc.menu"
 #define MC_LOCAL_MENU		".mc.menu"
-#define MC_HINT			"mc.hint"
+#define MC_HINT			"hints" PATH_SEP_STR "mc.hint"
 #define GLOBAL_KEYMAP_FILE	"mc.keymap"
 #define CHARSETS_LIST		"mc.charsets"
 #define MC_LIB_EXT		"mc.ext"

+ 8 - 11
src/cmd.c

@@ -1183,26 +1183,25 @@ get_random_hint (int force)
         return g_strdup ("");
     last_sec = tv.tv_sec;
 
-    data = load_mc_home_file (mc_home, mc_home_alt, MC_HINT, NULL);
-    if (!data)
-        return 0;
+    data = load_mc_home_file (mc_home_alt, MC_HINT, NULL);
+    if (data == NULL)
+        return NULL;
 
     /* get a random entry */
     srand (tv.tv_sec);
     len = strlen (data);
     start = rand () % len;
 
-    for (; start; start--)
-    {
+    for (; start != 0; start--)
         if (data[start] == '\n')
         {
             start++;
             break;
         }
-    }
-    eol = strchr (&data[start], '\n');
-    if (eol)
-        *eol = 0;
+
+    eol = strchr (data + start, '\n');
+    if (eol != NULL)
+        *eol = '\0';
 
     /* hint files are stored in utf-8 */
     /* try convert hint file from utf-8 to terminal encoding */
@@ -1211,9 +1210,7 @@ get_random_hint (int force)
     {
         buffer = g_string_new ("");
         if (str_convert (conv, &data[start], buffer) != ESTR_FAILURE)
-        {
             result = g_strdup (buffer->str);
-        }
         g_string_free (buffer, TRUE);
         str_close_conv (conv);
     }

+ 2 - 1
src/help.c

@@ -57,6 +57,7 @@
 #include "lib/tty/mouse.h"
 #include "lib/skin.h"
 #include "lib/strutil.h"
+#include "lib/fileloc.h"
 
 #include "dialog.h"             /* For Dlg_head */
 #include "widget.h"             /* For Widget */
@@ -965,7 +966,7 @@ interactive_display (const char *filename, const char *node)
     if (filename != NULL)
         filedata = load_file (filename);
     else
-        filedata = load_mc_home_file (mc_home, mc_home_alt, "mc.hlp", &hlpfile);
+        filedata = load_mc_home_file (mc_home_alt, "mc.hlp", &hlpfile);
 
     if (filedata == NULL)
         message (D_ERROR, MSG_ERROR, _("Cannot open file %s\n%s"),