~ubuntu-branches/ubuntu/raring/workrave/raring-proposed

« back to all changes in this revision

Viewing changes to intl/eval-plural.h

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Jordi Mallach
  • Date: 2012-05-28 11:29:40 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20120528112940-bbbsjkk30fom9s8x
Tags: 1.9.909+abc941eb70-1
[ Francois Marier ]
* New upstream snapshot
  - Drop leak-fix patch (applied upstream)
  - Document how the tarball is built in README.source
* Build GNOME applets and use gsettings
* Massive update of Build-Depends as per configure.ac

* Update README.source with snapshot instructions
* Switch to machine-readable copyright file
* Update alioth git repo links
* Bump debhelper version to 9
* Bump Standards-Version to 3.9.3

[ Jordi Mallach ]
* Avoid references to GNU/Linux in manpage.
* Drop build dependency on libgnet-dev, it's obsolete and unneeded.
* Add myself to Uploaders.
* Rewrite d/rules into dh style.
  - Move all install tweaks to .install files.
  - Install manpages using dh_installman.
* As a side effect, the package installs arch-dependant data in the
  arch triplet directory; add the required Pre-Depends for m-a-support.
* Bring back GNOME Panel applet (for GNOME 3 fallback mode) and ship the
  new GNOME Shell extension (closes: #642514, #666100).
* Add private_dirs.patch: move libworkrave-private and GObject
  Introspection files to a private dir, so they are really out of the
  way, but disable it for now as it breaks the Shell extension.
* Move typelib out of the triplet dir as gobject-introspection is not
  M-A ready yet.
* Enable dh_autoreconf for the above patches.
* Add lintian overrides.
* Add necessary Breaks/Replaces as the xpm icon has moved to workrave-data.
* Prefix all debhelper files with package name.
* Suggest gnome-shell and gnome-panel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Plural expression evaluation.
2
 
   Copyright (C) 2000-2003 Free Software Foundation, Inc.
3
 
 
4
 
   This program is free software; you can redistribute it and/or modify it
5
 
   under the terms of the GNU Library General Public License as published
6
 
   by the Free Software Foundation; either version 2, or (at your option)
7
 
   any later version.
8
 
 
9
 
   This program is distributed in the hope that it will be useful,
10
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
   Library General Public License for more details.
13
 
 
14
 
   You should have received a copy of the GNU Library General Public
15
 
   License along with this program; if not, write to the Free Software
16
 
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
 
   USA.  */
18
 
 
19
 
#ifndef STATIC
20
 
#define STATIC static
21
 
#endif
22
 
 
23
 
/* Evaluate the plural expression and return an index value.  */
24
 
STATIC
25
 
unsigned long int
26
 
internal_function
27
 
plural_eval (struct expression *pexp, unsigned long int n)
28
 
{
29
 
  switch (pexp->nargs)
30
 
    {
31
 
    case 0:
32
 
      switch (pexp->operation)
33
 
        {
34
 
        case var:
35
 
          return n;
36
 
        case num:
37
 
          return pexp->val.num;
38
 
        default:
39
 
          break;
40
 
        }
41
 
      /* NOTREACHED */
42
 
      break;
43
 
    case 1:
44
 
      {
45
 
        /* pexp->operation must be lnot.  */
46
 
        unsigned long int arg = plural_eval (pexp->val.args[0], n);
47
 
        return ! arg;
48
 
      }
49
 
    case 2:
50
 
      {
51
 
        unsigned long int leftarg = plural_eval (pexp->val.args[0], n);
52
 
        if (pexp->operation == lor)
53
 
          return leftarg || plural_eval (pexp->val.args[1], n);
54
 
        else if (pexp->operation == land)
55
 
          return leftarg && plural_eval (pexp->val.args[1], n);
56
 
        else
57
 
          {
58
 
            unsigned long int rightarg = plural_eval (pexp->val.args[1], n);
59
 
 
60
 
            switch (pexp->operation)
61
 
              {
62
 
              case mult:
63
 
                return leftarg * rightarg;
64
 
              case divide:
65
 
#if !INTDIV0_RAISES_SIGFPE
66
 
                if (rightarg == 0)
67
 
                  raise (SIGFPE);
68
 
#endif
69
 
                return leftarg / rightarg;
70
 
              case module:
71
 
#if !INTDIV0_RAISES_SIGFPE
72
 
                if (rightarg == 0)
73
 
                  raise (SIGFPE);
74
 
#endif
75
 
                return leftarg % rightarg;
76
 
              case plus:
77
 
                return leftarg + rightarg;
78
 
              case minus:
79
 
                return leftarg - rightarg;
80
 
              case less_than:
81
 
                return leftarg < rightarg;
82
 
              case greater_than:
83
 
                return leftarg > rightarg;
84
 
              case less_or_equal:
85
 
                return leftarg <= rightarg;
86
 
              case greater_or_equal:
87
 
                return leftarg >= rightarg;
88
 
              case equal:
89
 
                return leftarg == rightarg;
90
 
              case not_equal:
91
 
                return leftarg != rightarg;
92
 
              default:
93
 
                break;
94
 
              }
95
 
          }
96
 
        /* NOTREACHED */
97
 
        break;
98
 
      }
99
 
    case 3:
100
 
      {
101
 
        /* pexp->operation must be qmop.  */
102
 
        unsigned long int boolarg = plural_eval (pexp->val.args[0], n);
103
 
        return plural_eval (pexp->val.args[boolarg ? 1 : 2], n);
104
 
      }
105
 
    }
106
 
  /* NOTREACHED */
107
 
  return 0;
108
 
}