Use exerc instead of ano to choose encoding lengths
authorAlexandre Oliva <lxoliva@fsfla.org>
Sun, 9 Mar 2014 03:29:54 +0000 (00:29 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.info>
Mon, 10 Mar 2014 11:33:31 +0000 (08:33 -0300)
We key sizes on exerc, not on the calendar year the declaration refers
to, so compare exerc instead of ano.  Also, test latest years first.

rnet_encode.c

index 559b17f..2bf705a 100644 (file)
@@ -71,12 +71,12 @@ int rnet_encode(struct rnet_decfile *decfile, struct rnet_message **msg)
        versao_pgd = strtoul(rnet_decfile_get_header_field(decfile, "nr_versao"), NULL, 10);
        ret = strtoul(rnet_decfile_get_header_field(decfile, "in_ret"), NULL, 10);
 
-       if (!strcmp(ano, "2013")) {
-               header_start = RNET_HEADER_START_2013;
-               header_end = RNET_HEADER_END_2013;
-       } else if (!strcmp(ano, "2014")) {
+       if (!strcmp(exerc, "2014")) {
                header_start = RNET_HEADER_START_2014;
                header_end = RNET_HEADER_END_2014;
+       } else if (!strcmp(exerc, "2013")) {
+               header_start = RNET_HEADER_START_2013;
+               header_end = RNET_HEADER_END_2013;
        } else {
                return -EINVAL;
        }