Skip to content
Tcl Source Code History Of Ticket beecfca5fd
Login

History Of Ticket beecfca5fd

Artifacts Associated With Ticket beecfca5fd

  1. Ticket change [897933be16] (rid 239462) by emiliano on 2025-04-21 13:11:39:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      The function Tcl_ParseArgsObjv() behaves differently depending on whether the last argument, remObjv, is null or not. In the case of null last argument, it errors out when parses an unrecognized argument. The error message, however, is not on par with other functions like Tcl_GetIndexFromObj(). For example:
      
      C side table:
      
          const Tcl_ArgvInfo argsTable[] = {
              {TCL_ARGV_STRING,  "-command",    NULL     , &command,    NULL, NULL},
              {TCL_ARGV_GENFUNC, "-flush",      ParseBool, &flush  ,    NULL, NULL},
              {TCL_ARGV_STRING,  "-variable",   NULL,      &variable,   NULL, NULL},
              {TCL_ARGV_GENFUNC, "-watchunset", ParseBool, &watchunset, NULL, NULL},
              TCL_ARGV_TABLE_END
          };
      
      Tcl result:
      
      % parseargs -foo asd
      unrecognized argument "-foo"
      %
      
      Compare, for example, with other standard error messages
      
      % lsort -foo {}
      bad option "-foo": must be -ascii, -command, -decreasing, -dictionary, -increasing, -index, -indices, -integer, -nocase, -real, -stride, or -unique
      % 
      
      Since Tcl_ParseArgsObjv() already provides a way to print a helpful error message with TCL_ARGS_AUTO_HELP (or the corresponding full entry with TCL_ARGV_HELP type), I think it would be better to add this information after the terse 'unrecognized argument "-foo"' error message.
      
      The attached patch implements such change, resulting instead in
      
      % parsewithout -foo asd
      unrecognized argument "-foo"
      Command-specific options:
       -command:    
       -flush:      
       -variable:   
       -watchunset: 
      %
      
      Note that when remObjv option is not null the function doesn't error out on unrecognized options, copying them out to remObjv instead.
      
    5. foundin initialized to: "9.0"
    6. is_private initialized to: "0"
    7. login: "emiliano"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "emiliano"
    13. subsystem initialized to: "- New Builtin Commands"
    14. title initialized to: "Tcl_ParseArgsObjv unhelpful error message"
    15. type initialized to: "RFE"
  2. Add attachment "parseargs.diff" [8ae3a41ad5] (rid 239464) by emiliano on 2025-04-21 13:12:54.