[MPlayer-cvslog] r34264 - in trunk/gui/util: string.c string.h
ib
subversion at mplayerhq.hu
Wed Oct 26 17:40:47 CEST 2011
Author: ib
Date: Wed Oct 26 17:40:47 2011
New Revision: 34264
Log:
Cosmetic: Rename TranslateFilename()'s parameter names.
Additionally, add a doxygen comment and prefer *guiInfo.Filename
for cosmetic reasons.
Modified:
trunk/gui/util/string.c
trunk/gui/util/string.h
Modified: trunk/gui/util/string.c
==============================================================================
--- trunk/gui/util/string.c Wed Oct 26 17:14:06 2011 (r34263)
+++ trunk/gui/util/string.c Wed Oct 26 17:40:47 2011 (r34264)
@@ -236,7 +236,18 @@ void setddup(char **old, const char *dir
sprintf(*old, "%s/%s", dir, name);
}
-char *TranslateFilename(int c, char *tmp, size_t tmplen)
+/**
+ * @brief Convert #guiInfo member Filename.
+ *
+ * @param how 0 (cut file path and extension),
+ * 1 (additionally, convert lower case) or
+ * 2 (additionally, convert upper case)
+ * @param fname pointer to a buffer to receive the converted Filename
+ * @param maxlen size of @a fname buffer
+ *
+ * @return pointer to @a fname buffer
+ */
+char *TranslateFilename(int how, char *fname, size_t maxlen)
{
int i;
char *p;
@@ -244,7 +255,7 @@ char *TranslateFilename(int c, char *tmp
switch (guiInfo.StreamType) {
case STREAMTYPE_FILE:
- if (guiInfo.Filename && guiInfo.Filename[0]) {
+ if (guiInfo.Filename && *guiInfo.Filename) {
p = strrchr(guiInfo.Filename,
#if HAVE_DOS_PATHS
'\\');
@@ -253,61 +264,61 @@ char *TranslateFilename(int c, char *tmp
#endif
if (p)
- av_strlcpy(tmp, p + 1, tmplen);
+ av_strlcpy(fname, p + 1, maxlen);
else
- av_strlcpy(tmp, guiInfo.Filename, tmplen);
+ av_strlcpy(fname, guiInfo.Filename, maxlen);
- len = strlen(tmp);
+ len = strlen(fname);
- if (len > 3 && tmp[len - 3] == '.')
- tmp[len - 3] = 0;
- else if (len > 4 && tmp[len - 4] == '.')
- tmp[len - 4] = 0;
- else if (len > 5 && tmp[len - 5] == '.')
- tmp[len - 5] = 0;
+ if (len > 3 && fname[len - 3] == '.')
+ fname[len - 3] = 0;
+ else if (len > 4 && fname[len - 4] == '.')
+ fname[len - 4] = 0;
+ else if (len > 5 && fname[len - 5] == '.')
+ fname[len - 5] = 0;
} else
- av_strlcpy(tmp, MSGTR_NoFileLoaded, tmplen);
+ av_strlcpy(fname, MSGTR_NoFileLoaded, maxlen);
break;
case STREAMTYPE_STREAM:
- av_strlcpy(tmp, guiInfo.Filename, tmplen);
+ av_strlcpy(fname, guiInfo.Filename, maxlen);
break;
#ifdef CONFIG_VCD
case STREAMTYPE_VCD:
- snprintf(tmp, tmplen, MSGTR_Title, guiInfo.Track - 1);
+ snprintf(fname, maxlen, MSGTR_Title, guiInfo.Track - 1);
break;
#endif
#ifdef CONFIG_DVDREAD
case STREAMTYPE_DVD:
if (guiInfo.Chapter)
- snprintf(tmp, tmplen, MSGTR_Chapter, guiInfo.Chapter);
+ snprintf(fname, maxlen, MSGTR_Chapter, guiInfo.Chapter);
else
- av_strlcat(tmp, MSGTR_NoChapter, tmplen);
+ av_strlcat(fname, MSGTR_NoChapter, maxlen);
break;
#endif
default:
- av_strlcpy(tmp, MSGTR_NoMediaOpened, tmplen);
+ av_strlcpy(fname, MSGTR_NoMediaOpened, maxlen);
break;
}
- if (c) {
- for (i = 0; tmp[i]; i++) {
+ if (how) {
+ for (i = 0; fname[i]; i++) {
int t = 0;
- if (c == 1)
- if (tmp[i] >= 'A' && tmp[i] <= 'Z')
+ if (how == 1)
+ if (fname[i] >= 'A' && fname[i] <= 'Z')
t = 32;
- if (c == 2)
- if (tmp[i] >= 'a' && tmp[i] <= 'z')
+ if (how == 2)
+ if (fname[i] >= 'a' && fname[i] <= 'z')
t = -32;
- tmp[i] = (char)(tmp[i] + t);
+ fname[i] = (char)(fname[i] + t);
}
}
- return tmp;
+ return fname;
}
Modified: trunk/gui/util/string.h
==============================================================================
--- trunk/gui/util/string.h Wed Oct 26 17:14:06 2011 (r34263)
+++ trunk/gui/util/string.h Wed Oct 26 17:40:47 2011 (r34264)
@@ -29,7 +29,7 @@ void setddup(char **old, const char *dir
void setdup(char **old, const char *str);
char *strlower(char *in);
char *strswap(char *in, char from, char to);
-char *TranslateFilename(int c, char *tmp, size_t tmplen);
+char *TranslateFilename(int how, char *fname, size_t maxlen);
char *trim(char *in);
#endif /* MPLAYER_GUI_STRING_H */
More information about the MPlayer-cvslog
mailing list