[PATCH setxkbmap] Set of macros converted to enum type.

Peter Hutterer peter.hutterer at who-t.net
Thu Feb 17 16:02:16 PST 2011


On Thu, Feb 17, 2011 at 10:41:29PM +0300, Van de Bugger wrote:
> 
> Signed-off-by: Van de Bugger <van.de.bugger at gmail.com>
> ---
>  setxkbmap.c |   27 +++++++++++++++------------
>  1 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/setxkbmap.c b/setxkbmap.c
> index 0c43be5..e47278d 100644
> --- a/setxkbmap.c
> +++ b/setxkbmap.c
> @@ -57,15 +57,18 @@
>  #define DFLT_XKB_MODEL "pc105"
>  #endif
>  
> -/* Values used in svSrc to state how a value was obtained. The order of these
> +/* Constants to state how a value was obtained. The order of these
>   * is important, the bigger the higher the priority.
>   * e.g. FROM_CONFIG overrides FROM_SERVER */
> -#define UNDEFINED       0
> -#define FROM_SERVER     1       /* retrieved from server at runtime */
> -#define FROM_RULES      2       /* xkb rules file */
> -#define FROM_CONFIG     3       /* command-line specified config file */
> -#define FROM_CMD_LINE   4       /* specified at the cmdline */
> -#define NUM_SOURCES     5
> +enum source { 
> +    UNDEFINED = 0,
> +    FROM_SERVER,          /* Retrieved from server at runtime. */
> +    FROM_RULES,           /* Xkb rules file. */
> +    FROM_CONFIG,          /* Command-line specified config file. */
> +    FROM_CMD_LINE,        /* Specified at the cmdline. */
> +    NUM_SOURCES     
> +};
> +typedef enum source source_t;

I'd prefer it if you skipped the typedef.
an "enum source src" is much more expressive than "source_t src"

Cheers,
  Peter

>  
>  /***====================================================================***/
>  static Bool print = False;
> @@ -86,7 +89,7 @@ static char *srcName[NUM_SOURCES] = {
>  struct setting {
>      char const * name;  /* Human-readable setting name. Used for error reporting. */
>      char *       value; /* Holds the value. */
> -    int          src;   /* Holds the source. */
> +    source_t     src;   /* Holds the source. */
>  };
>  
>  typedef struct setting setting_t;
> @@ -173,8 +176,8 @@ static int deviceSpec = XkbUseCoreKbd;
>  Bool addToList(list_t * list, char *newVal);
>  void usage(int argc, char **argv);
>  void dumpNames(Bool wantRules, Bool wantCNames);
> -void trySetString(setting_t * setting, char *newVal, int src);
> -Bool setOptString(int *arg, int argc, char **argv, setting_t * setting, int src);
> +void trySetString(setting_t * setting, char *newVal, source_t src);
> +Bool setOptString(int *arg, int argc, char **argv, setting_t * setting, source_t src);
>  int parseArgs(int argc, char **argv);
>  Bool getDisplay(int argc, char **argv);
>  Bool getServerValues(void);
> @@ -311,7 +314,7 @@ dumpNames(Bool wantRules, Bool wantCNames)
>   * @param which What value is it (one of RULES_NDX, CONFIG_NDX, ...)
>   */
>  void
> -trySetString(setting_t * setting, char *newVal, int src)
> +trySetString(setting_t * setting, char *newVal, source_t src)
>  {
>      if (setting->value != NULL)
>      {
> @@ -337,7 +340,7 @@ trySetString(setting_t * setting, char *newVal, int src)
>  }
>  
>  Bool
> -setOptString(int *arg, int argc, char **argv, setting_t * setting, int src)
> +setOptString(int *arg, int argc, char **argv, setting_t * setting, source_t src)
>  {
>      int ndx;
>      char *opt;
> -- 
> 1.7.4
> 
> 
> 


More information about the xorg-devel mailing list