Fixed compatibility of output.
[AROS.git] / compiler / alib / invertstring.c
blob1d689b792c4f3f04d442bdbdf744ceccd9beb51a
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <libraries/commodities.h>
7 #include <proto/commodities.h>
8 #include <proto/exec.h>
9 #include <proto/alib.h>
10 #include <exec/memory.h>
11 #include <devices/keymap.h>
12 #include <devices/inputevent.h>
14 extern struct Library *CxBase;
16 /*****************************************************************************
18 NAME */
20 struct InputEvent *InvertString(
22 /* SYNOPSIS */
24 STRPTR str,
25 struct KeyMap *km
27 /* FUNCTION
28 Return a linked list of input events which would produce the string
29 'str' in the reverse order, with the keymap 'km'. To get a list of
30 events in the right order, just use InvertStringForwd(). InverString()
31 is only there to provide compatibility with the original function,
32 which indeed reversed the order of the supplied string.
34 INPUTS
35 str -- pointer to a (NULL-terminated) string that may contain
36 * ANSI character codes
37 * backslash-escaped characters:
38 \n -- carriage return
39 \r -- carriage return
40 \t -- tab
41 \\ -- backslash
42 * a description of an input event a la ParseIX() surrounded
43 by angle brackets
45 km -- keymap to use for the conversion or NULL to use the default
46 keymap
48 RESULT
49 A linked list of input events or NULL if something went wrong.
51 NOTES
53 EXAMPLE
54 An example string: "\n<shift alt a> olleH"
56 BUGS
58 SEE ALSO
59 commodities.library/ParseIX(), InvertStringForwd(), FreeIEvents()
61 INTERNALS
62 Ought to have an extra \< for < not starting an IX expression.
64 HISTORY
66 ******************************************************************************/
68 struct InputEvent *first, *second, *third, *fourth;
69 if ((first = InvertStringForwd(str, km)))
71 fourth = first;
72 third = first->ie_NextEvent;
73 while (third)
75 second = first;
76 first = third;
77 third = first->ie_NextEvent;
78 first->ie_NextEvent = second;
80 fourth->ie_NextEvent = NULL;
82 return first;
83 } /* InvertString */