Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In function `_start':
- (.text+0x18): undefined reference to `main'
- /tmp/ccjmG33v.o: In function `plugin_init':
- plugin.c:(.text+0x9e): undefined reference to `register_callback'
- plugin.c:(.text+0xc6): undefined reference to `register_callback'
- collect2: ld returned 1 exit status
- make: *** [plugin.o] Error 1
- PLUGINS_DIR = /usr/lib/gcc/i686-linux-gnu/4.6/plugin/include
- INCLUDES =
- -I$(PLUGINS_DIR)
- DEFINES = -Dbool=int -DTRUE=1 -DFALSE=0
- plugin.so : plugin.o
- gcc -shared -Wl,-export-dynamic -o plugin.so plugin.o
- %.o : %.c
- gcc $(DEFINES) $(INCLUDES) -fPIC -o $@ $^
- clean :
- rm *.o *.so
- #include <aspell.h>
- #include <gcc-plugin.h>
- #include <coretypes.h>
- #include <diagnostic.h>
- #include <gimple.h>
- #include <tree.h>
- #include <tree-flow.h>
- #include <tree-pass.h>
- #define is_alpha(c) (((c)>64 && (c)<91) || ((c)>96 && (c)<123))
- int plugin_is_GPL_compatible = 1;
- static AspellSpeller *speller_g;
- /* Help info about the plugin if one were to use gcc's --version --help */
- static struct plugin_info speller_info =
- {
- .version = "42",
- .help = "Hahahaha yeaaaaa....",
- };
- static struct plugin_gcc_version speller_ver =
- {
- .basever = "4.6",
- };
- /* We don't need to run any tests before we execute our plugin pass */
- static bool speller_gate(void)
- {
- return true;
- }
- static const_tree is_str_cst(const_tree node)
- {
- /*
- const_tree str = node;
- // Filter out types we are ignoring
- if (TREE_CODE(str) == VAR_DECL)
- {
- if (!(str = DECL_INITIAL(node)))
- return NULL_TREE;
- else if (TREE_OPERAND_LENGTH(str))
- str = TREE_OPERAND(str, 0);
- }
- else if (TREE_CODE(str) == ADDR_EXPR &&
- TREE_OPERAND_LENGTH(str) > 0)
- str = TREE_OPERAND(str, 0);
- if (TREE_CODE(str) != STRING_CST &&
- TREE_OPERAND_LENGTH(str) > 0)
- str = TREE_OPERAND(str, 0);
- if (TREE_CODE(str) != STRING_CST)
- return NULL_TREE;
- else
- return str;
- */
- }
- static AspellSpeller *init_spellchecker(void)
- {
- /*
- AspellConfig *cfg;
- AspellCanHaveError *err;
- // Configure and instantiate a spell checker
- cfg = new_aspell_config();
- aspell_config_replace(cfg, "lang", "en_US");
- err = new_aspell_speller(cfg);
- if (aspell_error_number(err) != 0)
- {
- puts(aspell_error_message(err));
- return NULL;
- }
- return to_aspell_speller(err);
- */
- }
- static void spell_check(const_gimple stmt, const_tree str)
- {
- /*
- char buf[32] = {0};
- const char *data, *end;
- data = TREE_STRING_POINTER(str);
- printf("Spell checking string: '%s'n", data);
- while (*data)
- {
- // Skip non alphas including whitespace
- while (!is_alpha(data[0]))
- {
- if (data[0] == '