Ticket #3547: mc-3547-cleanup-args.c-reduce-function-scope-for-mcedit_arg_new.patch

File mc-3547-cleanup-args.c-reduce-function-scope-for-mcedit_arg_new.patch, 4.0 KB (added by and, 7 years ago)
  • src/args.c

    From 3828bc83a176a780542f62d30303aeb9ac4f7476 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sun, 17 Jan 2016 16:09:56 +0000
    Subject: [PATCH] cleanup: args.c recude function scope for mcedit_arg_*
    
    reduce to scope for
        mcedit_arg_new (const char *file_name, long line_number)
        mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
    and move to file scope section
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/args.c | 72 +++++++++++++++++++++++++++++++-------------------------------
     src/args.h |  2 --
     2 files changed, 36 insertions(+), 38 deletions(-)
    
    diff --git a/src/args.c b/src/args.c
    index 0ee7de6..a93defc 100644
    a b parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer da 
    471471 
    472472/* --------------------------------------------------------------------------------------------- */ 
    473473/** 
     474 * Create mcedit_arg_t object from vfs_path_t object and the line number. 
     475 * 
     476 * @param file_vpath  file path object 
     477 * @param line_number line number. If value is 0, try to restore saved position. 
     478 * @return mcedit_arg_t object 
     479 */ 
     480 
     481static mcedit_arg_t * 
     482mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number) 
     483{ 
     484    mcedit_arg_t *arg; 
     485 
     486    arg = g_new (mcedit_arg_t, 1); 
     487    arg->file_vpath = file_vpath; 
     488    arg->line_number = line_number; 
     489 
     490    return arg; 
     491} 
     492 
     493/* --------------------------------------------------------------------------------------------- */ 
     494/** 
     495 * Create mcedit_arg_t object from file name and the line number. 
     496 * 
     497 * @param file_name   file name 
     498 * @param line_number line number. If value is 0, try to restore saved position. 
     499 * @return mcedit_arg_t object 
     500 */ 
     501 
     502static mcedit_arg_t * 
     503mcedit_arg_new (const char *file_name, long line_number) 
     504{ 
     505    return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number); 
     506} 
     507 
     508/* --------------------------------------------------------------------------------------------- */ 
     509/** 
    474510 * Get list of filenames (and line numbers) from command line, when mc called as editor 
    475511 * 
    476512 * @param argc count of all arguments 
    mc_setup_by_args (int argc, char **argv, GError ** mcerror) 
    795831 
    796832/* --------------------------------------------------------------------------------------------- */ 
    797833/** 
    798  * Create mcedit_arg_t object from file name and the line number. 
    799  * 
    800  * @param file_name   file name 
    801  * @param line_number line number. If value is 0, try to restore saved position. 
    802  * @return mcedit_arg_t object 
    803  */ 
    804  
    805 mcedit_arg_t * 
    806 mcedit_arg_new (const char *file_name, long line_number) 
    807 { 
    808     return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number); 
    809 } 
    810  
    811 /* --------------------------------------------------------------------------------------------- */ 
    812 /** 
    813  * Create mcedit_arg_t object from vfs_path_t object and the line number. 
    814  * 
    815  * @param file_vpath  file path object 
    816  * @param line_number line number. If value is 0, try to restore saved position. 
    817  * @return mcedit_arg_t object 
    818  */ 
    819  
    820 mcedit_arg_t * 
    821 mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number) 
    822 { 
    823     mcedit_arg_t *arg; 
    824  
    825     arg = g_new (mcedit_arg_t, 1); 
    826     arg->file_vpath = file_vpath; 
    827     arg->line_number = line_number; 
    828  
    829     return arg; 
    830 } 
    831  
    832 /* --------------------------------------------------------------------------------------------- */ 
    833 /** 
    834834 * Free the mcedit_arg_t object. 
    835835 * 
    836836 * @param arg mcedit_arg_t object 
  • src/args.h

    diff --git a/src/args.h b/src/args.h
    index f33c07c..53ff9ea 100644
    a b gboolean mc_args_parse (int *argc, char ***argv, const char *translation_domain, 
    5050gboolean mc_args_show_info (void); 
    5151gboolean mc_setup_by_args (int argc, char **argv, GError ** mcerror); 
    5252 
    53 mcedit_arg_t *mcedit_arg_new (const char *file_name, long line_number); 
    54 mcedit_arg_t *mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number); 
    5553void mcedit_arg_free (mcedit_arg_t * arg); 
    5654 
    5755/*** inline functions ****************************************************************************/