Skip to content

Instantly share code, notes, and snippets.

@amalloy
Last active April 14, 2017 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/645cd1acdb1fccabe61bb18fdc7fb803 to your computer and use it in GitHub Desktop.
Save amalloy/645cd1acdb1fccabe61bb18fdc7fb803 to your computer and use it in GitHub Desktop.
(defun ptr-to-ref (symbol)
(interactive "sConvert local pointer variable to reference: ")
(save-excursion
(narrow-to-defun)
(unwind-protect
(dolist (replacement (list (cons (concat "\\b" symbol "\\b\\([^*&_-]\\)")
(concat "&" symbol "\\1"))
(cons (concat "\\b" symbol "->")
(concat symbol "."))
(cons (concat "\\*&" symbol)
symbol)))
(beginning-of-buffer)
(search-forward ")")
(while (re-search-forward (car replacement) nil t)
(replace-match (cdr replacement))))
(widen))))
#!/bin/bash
for fname in $@
do
find . -name '*.cc' | xargs perl -pi -e "s/(\\b$fname\\()/\$1*/g unless (m/^\w+\[*&]* $fname/m);"
find . -name '*.cc' | xargs perl -pi -e "s/(\\b$fname\\()\*&/\$1/g;"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment