1
1

Merge branch '2250_mcext_case_insense'

* 2250_mcext_case_insense:
  Implement case insensitive for type keyword.
  Use shell instead of regex for simple regular expressions.
  Implement case insensitive for shell keyword.
  Implement case insensitive for regex keyword.
  Ticket #2250: implement case-insensitive patterns in mc.ext.
Этот коммит содержится в:
Andrew Borodin 2012-08-05 13:42:08 +04:00
родитель 06e874ea21 b71f35ee60
Коммит bcfb8c8f98
2 изменённых файлов: 194 добавлений и 127 удалений

Просмотреть файл

@ -12,14 +12,23 @@
# i.e. matches all the files *desc . Example: .tar matches *.tar;
# if it doesn't start with a dot, it matches only a file of that name)
#
# shell/i (desc is, when starting with a dot, any extension (no wildcars),
# The same as shell but with case insensitive.
#
# regex (desc is an extended regular expression)
# Please note that we are using the GNU regex library and thus
# \| matches the literal | and | has special meaning (or) and
# () have special meaning and \( \) stand for literal ( ).
#
# regex/i (desc is an extended regular expression)
# The same as regex but with case insensitive.
#
# type (file matches this if `file %f` matches regular expression desc
# (the filename: part from `file %f` is removed))
#
# type/i (file matches this if `file %f` matches regular expression desc)
# The same as type but with case insensitive.
#
# directory (matches any directory matching regular expression desc)
#
# include (matches an include directive)
@ -113,7 +122,7 @@ regex/\.t([gp]?z|ar\.g?[zZ])$|\.ipk|\.gem$
Open=%cd %p/utar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.gz
regex/\.tar\.bz$
shell/.tar.bz
# Open=%cd %p/utar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.bzip
@ -132,17 +141,17 @@ regex/\.t(ar\.xz|xz)$
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.xz
# .tar.F - used in QNX
regex/\.tar\.F$
shell/.tar.F
# Open=%cd %p/utar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.F
# .qpr/.qpk - QNX Neutrino package installer files
regex/\.(qp[rk])$
regex/\.qp[rk]$
Open=%cd %p/utar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.qpr
# tar
regex/\.(tar|TAR)$
shell/i/.tar
Open=%cd %p/utar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar
@ -152,27 +161,27 @@ type/^LHa\ .*archive
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view lha
# arj
regex/\.a(rj|[0-9][0-9])$
regex/i/\.a(rj|[0-9][0-9])$
Open=%cd %p/uarj://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view arj
# cab
regex/\.([cC][aA][bB])$
shell/i/.cab
Open=%cd %p/ucab://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cab
# ha
regex/\.([Hh][Aa])$
shell/i/.ha
Open=%cd %p/uha://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view ha
# rar
regex/\.[rR]([aA][rR]|[0-9][0-9])$
regex/i/\.r(ar|[0-9][0-9])$
Open=%cd %p/urar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view rar
# ALZip
regex/\.(alz|ALZ)$
shell/i/.alz
Open=%cd %p/ualz://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view alz
@ -189,12 +198,12 @@ shell/.cpio.gz
Open=%cd %p/ucpio://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.gz
shell/.cpio
shell/i/.cpio
Open=%cd %p/ucpio://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio
# 7zip archives (they are not man pages)
regex/\.(7z|7Z)$
shell/i/.7z
Open=%cd %p/u7z://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view 7z
@ -212,7 +221,7 @@ regex/(^|\.)ls-?lR(\.gz|Z|bz2)$
Open=%cd %p/lslR://
# trpm
regex/\.trpm$
shell/.trpm
Open=%cd %p/trpm://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view trpm
@ -221,7 +230,7 @@ regex/\.(src\.rpm|spm)$
Open=%cd %p/rpm://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view src.rpm
regex/\.rpm$
shell/.rpm
Open=%cd %p/rpm://
View=%view{ascii} @EXTHELPERSDIR@/package.sh view rpm
@ -241,7 +250,7 @@ shell/.deba
View=%view{ascii} @EXTHELPERSDIR@/package.sh view deba
# ISO9660
regex/\.([iI][sS][oO])$
shell/i/.iso
Open=%cd %p/iso9660://
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view iso9660
@ -257,7 +266,7 @@ regex/\.s?a$
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view ar
# gplib
regex/\.([Ll][Ii][Bb])$
shell/i/.lib
Open=%cd %p/ulib://
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view lib
@ -314,7 +323,7 @@ shell/.info
Open=@EXTHELPERSDIR@/text.sh open info
# Exception: .3gp are video files not manual pages
regex/\.(3[gG][pP])$
shell/i/.3gp
Include=video
# Manual page
@ -364,7 +373,7 @@ regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.xz %var{PAGER:more}
# CHM
regex/\.(chm|CHM)$
shell/i/.chm
Open=@EXTHELPERSDIR@/text.sh open chm
### Images ###
@ -417,84 +426,84 @@ include/image
### Sound files ###
regex/\.([wW][aA][vV]|[sS][nN][dD]|[vV][oO][cC]|[aA][uU]|[sS][mM][pP]|[aA][iI][fF][fF]|[sS][nN][dD])$
regex/i/\.(wav|snd|voc|au|smp|aiff|snd)$
Open=@EXTHELPERSDIR@/sound.sh open common
regex/\.([mM][oO][dD]|[sS]3[mM]|[xX][mM]|[iI][tT]|[mM][tT][mM]|669|[sS][tT][mM]|[uU][lL][tT]|[fF][aA][rR])$
regex/i/\.(mod|s3m|xm|it|mtm|669|stm|ult|far)$
Open=@EXTHELPERSDIR@/sound.sh open mod
regex/\.([wW][aA][wW]22)$
shell/i/.waw22
Open=@EXTHELPERSDIR@/sound.sh open wav22
regex/\.([mM][pP]3)$
shell/i/.mp3
Open=@EXTHELPERSDIR@/sound.sh open mp3
View=%view{ascii} @EXTHELPERSDIR@/sound.sh view mp3
regex/\.([oO][gG][gG|aA|vV|xX])$
regex/i/\.og[gavx]$
Open=@EXTHELPERSDIR@/sound.sh open ogg
View=%view{ascii} @EXTHELPERSDIR@/sound.sh view ogg
regex/\.([sS][pP][xX]|[fF][lL][aA][cC])$
regex/i/\.(spx|flac)$
Open=@EXTHELPERSDIR@/sound.sh open common
regex/\.([mM][iI][dD][iI]?|[rR][mM][iI][dD]?)$
regex/i/\.(midi?|rmid?)$
Open=@EXTHELPERSDIR@/sound.sh open midi
regex/\.([wW][mM][aA])$
shell/i/.wma
Open=@EXTHELPERSDIR@/sound.sh open wma
View=%view{ascii} @EXTHELPERSDIR@/sound.sh view wma
### Play lists ###
regex/\.([mM]3[uU]|[pP][lL][sS])$
regex/i/\.(m3u|pls)$
Open=@EXTHELPERSDIR@/sound.sh open playlist
### Video ###
regex/\.([aA][vV][iI])$
shell/i/.avi
Include=video
regex/\.([aA][sS][fFxX])$
regex/i/\.as[fx]$
Include=video
regex/\.([dD][iI][vV][xX])$
shell/i/.divx
Include=video
regex/\.([mM][kK][vV])$
shell/i/.mkv
Include=video
regex/\.([mM][oO][vV]|[qQ][tT])$
regex/i/\.(mov|qt)$
Include=video
regex/\.([mM][pP]4|[mM]4[vV]|[mM][pP][eE]?[gG])$
regex/i/\.(mp4|m4v|mpe?g)$
Include=video
# MPEG-2 TS container + H.264 codec
regex/\.([mM][tT][sS])$
shell/i/.mts
Include=video
regex/\.([tT][sS])$
shell/i/.ts
Include=video
regex/\.([vV][oO][bB])$
shell/i/.vob
Include=video
regex/\.([wW][mM][vV])$
shell/i/.wmv
Include=video
regex/\.([fF][lL][iIcCvV])$
regex/i/\.fl[icv]$
Include=video
regex/\.([oO][gG][mM])$
shell/i/.ogm
Include=video
regex/\.([rR][aA]?[mM])$
regex/i/\.ra?m$
Open=@EXTHELPERSDIR@/video.sh open ram
# WebM
regex/\.([wW][eE][bB][mM])$
shell/i/.webm
Include=video
type/WebM
@ -518,7 +527,7 @@ type/^PDF
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view pdf
# html
regex/\.([hH][tT][mM][lL]?)$
regex/i/\.html?$
Open=@EXTHELPERSDIR@/web.sh open html
View=%view{ascii} @EXTHELPERSDIR@/web.sh view html
@ -527,7 +536,7 @@ shell/.sdw
Open=@EXTHELPERSDIR@/doc.sh open ooffice
# StarOffice 6 and OpenOffice.org formats
regex/\.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg)$
regex/i/\.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg)$
Open=@EXTHELPERSDIR@/doc.sh open ooffice
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view odt
@ -536,7 +545,7 @@ shell/.abw
Open=@EXTHELPERSDIR@/doc.sh open abw
# Microsoft Word Document
regex/\.([Dd][oO][cCtT]|[Ww][rR][iI])$
regex/i/\.(do[ct]|wri)$
Open=@EXTHELPERSDIR@/doc.sh open msdoc
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msdoc
type/^Microsoft\ Word
@ -544,11 +553,11 @@ type/^Microsoft\ Word
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msdoc
# RTF document
regex/\.([rR][tT][fF])$
shell/i/.rtf
Open=@EXTHELPERSDIR@/doc.sh open msdoc
# Microsoft Excel Worksheet
regex/\.([xX][lL][sSwW])$
regex/i/\.xl[sw]$
Open=@EXTHELPERSDIR@/doc.sh open msxls
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls
type/^Microsoft\ Excel
@ -564,16 +573,16 @@ type/^FrameMaker
Open=@EXTHELPERSDIR@/doc.sh open framemaker
# DVI
regex/\.([dD][vV][iI])$
shell/i/.dvi
Open=@EXTHELPERSDIR@/doc.sh open dvi
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view dvi
# TeX
regex/\.([Tt][Ee][Xx])$
shell/i/.tex
Include=editor
# DjVu
regex/\.(djvu?|DJVU?)$
regex/i/\.djvu?$
Open=@EXTHELPERSDIR@/doc.sh open djvu
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view djvu
@ -592,7 +601,7 @@ regex/^Makefile.(PL|pl)$
Open=%var{PERL:perl} %f
# dbf
regex/\.([dD][bB][fF])$
shell/i/.dbf
Open=%view{ascii} @EXTHELPERSDIR@/misc.sh open dbf
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view dbf
@ -601,13 +610,13 @@ regex/\.(rexx?|cmd)$
Open=rexx %f %{Enter parameters};echo "Press ENTER";read y
# Disk images for Commodore computers (VIC20, C64, C128)
regex/\.(d64|D64)$
shell/i/.d64
Open=%cd %p/uc1541://
View=%view{ascii} c1541 %f -list
Extract=c1541 %f -extract
# Glade, a user interface designer for GTK+ and GNOME
regex/\.([Gg][Ll][Aa][Dd][Ee])$
shell/i/.glade
Open=@EXTHELPERSDIR@/misc.sh open glade
# Gettext Catalogs
@ -615,36 +624,36 @@ shell/.mo
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view mo
# lyx
regex/\.(lyx|LYX)$
shell/i/.lyx
Open=@EXTHELPERSDIR@/misc.sh open lyx
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view lyx
# torrent
regex/\.([tT][oO][rR][rR][eE][nN][tT])$
shell/i/.torrent
View=%view{ascii} @EXTHELPERSDIR@/misc.sh view torrent
### Plain compressed files ###
# ace
regex/\.(ace|ACE)$
shell/i/.ace
Open=%cd %p/uace://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view ace
Extract=unace x %f
# arc
regex/\.(arc|ARC)$
shell/i/.arc
Open=%cd %p/uarc://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view arc
Extract=arc x %f '*'
Extract (with flags)=I=%{Enter any Arc flags:}; if test -n "$I"; then arc x $I %f; fi
# zip
type/^([Zz][Ii][Pp])\ archive
type/i/^zip\ archive
Open=%cd %p/uzip://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zip
# zoo
regex/\.([Zz][Oo][Oo])$
shell/i/.zoo
Open=%cd %p/uzoo://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zoo

Просмотреть файл

@ -591,10 +591,11 @@ get_file_encoding_local (const vfs_path_t * filename_vpath, char *buf, int bufle
* Return 1 for match, 0 for no match, -1 errors.
*/
static int
regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_type)
static gboolean
regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_type,
gboolean case_insense, GError ** error)
{
int found = 0;
gboolean found = FALSE;
/* Following variables are valid if *have_type is 1 */
static char content_string[2048];
@ -605,7 +606,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
static int got_data = 0;
if (!use_file_to_check_type)
return 0;
return FALSE;
if (*have_type == 0)
{
@ -621,7 +622,16 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
localfile_vpath = mc_getlocalcopy (filename_vpath);
if (localfile_vpath == NULL)
return -1;
{
char *filename;
filename = vfs_path_to_str (filename_vpath);
g_propagate_error (error,
g_error_new (MC_ERROR, -1,
_("Cannot fetch a local copy of %s"), filename));
g_free (filename);
return FALSE;
}
realname = vfs_path_get_last_path_str (localfile_vpath);
@ -684,12 +694,27 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
}
if (got_data == -1)
return -1;
if (content_string[0] != '\0'
&& mc_search (ptr, content_string + content_shift, MC_SEARCH_T_REGEX))
{
found = 1;
g_propagate_error (error, g_error_new (MC_ERROR, -1, _("Pipe failed")));
return FALSE;
}
if (content_string[0] != '\0')
{
mc_search_t *search;
search = mc_search_new (ptr, -1);
if (search != NULL)
{
search->search_type = MC_SEARCH_T_REGEX;
search->is_case_sensitive = !case_insense;
found = mc_search_run (search, content_string + content_shift, 0, -1, NULL);
mc_search_free (search);
}
else
{
g_propagate_error (error, g_error_new (MC_ERROR, -1, _("Regular expression error")));
}
}
return found;
@ -725,8 +750,8 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
{
char *filename, *p, *q, *r, c;
size_t file_len;
int found = 0;
int error_flag = 0;
gboolean found = FALSE;
gboolean error_flag = FALSE;
int ret = 0;
struct stat mystat;
int view_at_line_number;
@ -751,8 +776,8 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
if (data == NULL)
{
char *extension_file;
int mc_user_ext = 1;
int home_error = 0;
gboolean mc_user_ext = TRUE;
gboolean home_error = FALSE;
extension_file = mc_config_get_full_path (MC_FILEBIND_FILE);
if (!exist_file (extension_file))
@ -765,7 +790,7 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
g_free (extension_file);
extension_file = mc_build_filename (mc_global.share_data_dir, MC_LIB_EXT, NULL);
}
mc_user_ext = 0;
mc_user_ext = FALSE;
}
g_file_get_contents (extension_file, &data, NULL, NULL);
@ -773,21 +798,20 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
if (data == NULL)
return 0;
if (!strstr (data, "default/"))
if (strstr (data, "default/") == NULL)
{
if (!strstr (data, "regex/") && !strstr (data, "shell/") && !strstr (data, "type/"))
if (strstr (data, "regex/") == NULL && strstr (data, "shell/") == NULL &&
strstr (data, "type/") == NULL)
{
g_free (data);
data = NULL;
if (mc_user_ext)
if (!mc_user_ext)
{
home_error = 1;
goto check_stock_mc_ext;
}
else
{
char *title = g_strdup_printf (_(" %s%s file error"),
mc_global.sysconfig_dir, MC_LIB_EXT);
char *title;
title = g_strdup_printf (_(" %s%s file error"),
mc_global.sysconfig_dir, MC_LIB_EXT);
message (D_ERROR, title, _("The format of the %smc.ext "
"file has changed with version 3.0. It seems that "
"the installation failed. Please fetch a fresh "
@ -796,12 +820,19 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
g_free (title);
return 0;
}
home_error = TRUE;
goto check_stock_mc_ext;
}
}
if (home_error)
{
char *filebind_filename = mc_config_get_full_path (MC_FILEBIND_FILE);
char *title = g_strdup_printf (_("%s file error"), filebind_filename);
char *filebind_filename;
char *title;
filebind_filename = mc_config_get_full_path (MC_FILEBIND_FILE);
title = g_strdup_printf (_("%s file error"), filebind_filename);
message (D_ERROR, title,
_("The format of the %s file has "
"changed with version 3.0. You may either want to copy "
@ -819,79 +850,106 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
filename = vfs_path_to_str (filename_vpath);
file_len = vfs_path_len (filename_vpath);
for (p = data; *p; p++)
for (p = data; *p != '\0'; p++)
{
for (q = p; *q == ' ' || *q == '\t'; q++);
if (*q == '\n' || !*q)
for (q = p; *q == ' ' || *q == '\t'; q++)
;
if (*q == '\n' || *q == '\0')
p = q; /* empty line */
if (*p == '#') /* comment */
while (*p && *p != '\n')
while (*p != '\0' && *p != '\n')
p++;
if (*p == '\n')
continue;
if (!*p)
if (*p == '\0')
break;
if (p == q)
{ /* i.e. starts in the first column, should be
* keyword/descNL
*/
found = 0;
gboolean case_insense;
found = FALSE;
q = strchr (p, '\n');
if (q == NULL)
q = strchr (p, 0);
q = strchr (p, '\0');
c = *q;
*q = 0;
*q = '\0';
if (include_target)
{
if ((strncmp (p, "include/", 8) == 0)
&& (strncmp (p + 8, include_target, include_target_len) == 0))
found = 1;
found = TRUE;
}
else if (!strncmp (p, "regex/", 6))
else if (strncmp (p, "regex/", 6) == 0)
{
mc_search_t *search;
p += 6;
/* Do not transform shell patterns, you can use shell/ for
* that
*/
if (mc_search (p, filename, MC_SEARCH_T_REGEX))
found = 1;
case_insense = (strncmp (p, "i/", 2) == 0);
if (case_insense)
p += 2;
search = mc_search_new (p, -1);
if (search != NULL)
{
search->search_type = MC_SEARCH_T_REGEX;
search->is_case_sensitive = !case_insense;
found = mc_search_run (search, filename, 0, file_len, NULL);
mc_search_free (search);
}
}
else if (!strncmp (p, "directory/", 10))
else if (strncmp (p, "directory/", 10) == 0)
{
if (S_ISDIR (mystat.st_mode) && mc_search (p + 10, filename, MC_SEARCH_T_REGEX))
found = 1;
found = TRUE;
}
else if (!strncmp (p, "shell/", 6))
else if (strncmp (p, "shell/", 6) == 0)
{
int (*cmp_func) (const char *s1, const char *s2, size_t n) = strncmp;
p += 6;
case_insense = (strncmp (p, "i/", 2) == 0);
if (case_insense)
{
p += 2;
cmp_func = strncasecmp;
}
if (*p == '.' && file_len >= (size_t) (q - p))
{
if (!strncmp (p, filename + file_len - (q - p), q - p))
found = 1;
if (cmp_func (p, filename + file_len - (q - p), q - p) == 0)
found = TRUE;
}
else
{
if ((size_t) (q - p) == file_len && !strncmp (p, filename, q - p))
found = 1;
if ((size_t) (q - p) == file_len && cmp_func (p, filename, q - p) == 0)
found = TRUE;
}
}
else if (!strncmp (p, "type/", 5))
else if (strncmp (p, "type/", 5) == 0)
{
int res;
GError *error = NULL;
p += 5;
res = regex_check_type (filename_vpath, p, &have_type);
if (res == 1)
found = 1;
if (res == -1)
error_flag = 1; /* leave it if file cannot be opened */
}
else if (!strncmp (p, "default/", 8))
{
found = 1;
case_insense = (strncmp (p, "i/", 2) == 0);
if (case_insense)
p += 2;
found = regex_check_type (filename_vpath, p, &have_type, case_insense, &error);
if (error != NULL)
{
g_error_free (error);
error_flag = TRUE; /* leave it if file cannot be opened */
}
}
else if (strncmp (p, "default/", 8) == 0)
found = TRUE;
*q = c;
p = q;
if (!*p)
if (*p == '\0')
break;
}
else
@ -899,31 +957,31 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
p = q;
q = strchr (p, '\n');
if (q == NULL)
q = strchr (p, 0);
q = strchr (p, '\0');
if (found && !error_flag)
{
r = strchr (p, '=');
if (r != NULL)
{
c = *r;
*r = 0;
*r = '\0';
if (strcmp (p, "Include") == 0)
{
char *t;
include_target = p + 8;
t = strchr (include_target, '\n');
if (t)
*t = 0;
if (t != NULL)
*t = '\0';
include_target_len = strlen (include_target);
if (t)
if (t != NULL)
*t = '\n';
*r = c;
p = q;
found = 0;
found = FALSE;
if (!*p)
if (*p == '\0')
break;
continue;
}
@ -950,13 +1008,13 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
}
}
p = q;
if (!*p)
if (*p == '\0')
break;
}
}
g_free (filename);
if (error_flag)
return -1;
ret = -1;
return ret;
}