[asterisk-commits] kpfleming: trunk r104594 - in /trunk: ./ main/file.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 27 10:54:15 CST 2008


Author: kpfleming
Date: Wed Feb 27 10:54:14 2008
New Revision: 104594

URL: http://svn.digium.com/view/asterisk?view=rev&rev=104594
Log:
Merged revisions 104593 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r104593 | kpfleming | 2008-02-27 10:53:06 -0600 (Wed, 27 Feb 2008) | 8 lines

fallback to standard English prompts properly when using new prompt directory layout

(closes issue #11831)
Reported by: IgorG
Patches:
      fallbacken.v1.diff uploaded by IgorG (license 20) (modified by me to improve code and conform rest of function to coding guidelines)


........

Modified:
    trunk/   (props changed)
    trunk/main/file.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/file.c
URL: http://svn.digium.com/view/asterisk/trunk/main/file.c?view=diff&rev=104594&r1=104593&r2=104594
==============================================================================
--- trunk/main/file.c (original)
+++ trunk/main/file.c Wed Feb 27 10:54:14 2008
@@ -467,33 +467,37 @@
  * which on success is filled with the matching filename.
  */
 static int fileexists_core(const char *filename, const char *fmt, const char *preflang,
-		char *buf, int buflen)
+			   char *buf, int buflen)
 {
 	int res = -1;
 	int langlen;	/* length of language string */
 	const char *c = strrchr(filename, '/');
 	int offset = c ? c - filename + 1 : 0;	/* points right after the last '/' */
 
-	if (preflang == NULL)
+	if (preflang == NULL) {
 		preflang = "";
+	}
 	langlen = strlen(preflang);
 	
-	if (buflen < langlen + strlen(filename) + 2) {
-		ast_log(LOG_WARNING, "buffer too small\n");
-		buf[0] = '\0'; /* set to empty */
-		buf = alloca(langlen + strlen(filename) + 2);	/* room for everything */
-	}
-	if (buf == NULL)
+	if (buflen < langlen + strlen(filename) + 4) {
+		ast_log(LOG_WARNING, "buffer too small, allocating larger buffer\n");
+		buf = alloca(langlen + strlen(filename) + 4);	/* room for everything */
+	}
+
+	if (buf == NULL) {
 		return 0;
-	buf[0] = '\0';
+	}
+
 	for (;;) {
 		if (ast_language_is_prefix) { /* new layout */
 			if (langlen) {
 				strcpy(buf, preflang);
 				buf[langlen] = '/';
 				strcpy(buf + langlen + 1, filename);
-			} else
-				strcpy(buf, filename);	/* first copy the full string */
+			} else {
+				strcpy(buf, "en/"); /* English - fallback if no file found in preferred language */
+				strcpy(buf + 3, filename);
+			}
 		} else { /* old layout */
 			strcpy(buf, filename);	/* first copy the full string */
 			if (langlen) {
@@ -503,15 +507,19 @@
 			}
 		}
 		res = ast_filehelper(buf, NULL, fmt, ACTION_EXISTS);
-		if (res > 0)		/* found format */
+		if (res > 0) {		/* found format */
 			break;
-		if (langlen == 0)	/* no more formats */
+		}
+		if (langlen == 0) {	/* no more formats */
 			break;
-		if (preflang[langlen] == '_') /* we are on the local suffix */
+		}
+		if (preflang[langlen] == '_') { /* we are on the local suffix */
 			langlen = 0;	/* try again with no language */
-		else
+		} else {
 			langlen = (c = strchr(preflang, '_')) ? c - preflang : 0;
-	}
+		}
+	}
+
 	return res;
 }
 




More information about the asterisk-commits mailing list