Function: ff-cc-hh-converter

ff-cc-hh-converter is a byte-compiled function defined in find-file.el.gz.

Signature

(ff-cc-hh-converter ARG)

Documentation

Discriminate file extensions.

Build up a new file list based possibly on part of the directory name and the name of the file passed in.

Source Code

;; Defined in /usr/src/emacs/lisp/find-file.el.gz
(defun ff-cc-hh-converter (arg)
  "Discriminate file extensions.
Build up a new file list based possibly on part of the directory name
and the name of the file passed in."
  (ff-string-match "\\(.*\\)/\\([^/]+\\)/\\([^.]+\\).\\([^/]+\\)$" arg)
  (let ((dire (match-string 2 arg))
        (file (match-string 3 arg))
        (extn (match-string 4 arg))
        return-list)
    (cond
     ;; fooZapJunk.cc => ZapJunk.{hh,h} or fooZapJunk.{hh,h}
     ((and (string= extn "cc")
           (ff-string-match "^\\([[:lower:]]+\\)\\([[:upper:]].+\\)$" file))
      (let ((stub  (match-string 2 file)))
        (setq dire (upcase (match-string 1 file)))
        (setq return-list (list (concat stub ".hh")
                                (concat stub ".h")
                                (concat file ".hh")
                                (concat file ".h")))
        ))
     ;; FOO/ZapJunk.hh => fooZapJunk.{cc,C} or ZapJunk.{cc,C}
     ((and (string= extn "hh") (ff-upcase-p dire) file)
      (let ((stub (concat (downcase dire) file)))
        (setq return-list (list (concat stub ".cc")
                                (concat stub ".C")
                                (concat file ".cc")
                                (concat file ".C")))
        ))
     ;; zap.cc => zap.hh or zap.h
     ((string= extn "cc")
      (let ((stub file))
        (setq return-list (list (concat stub ".hh")
                                (concat stub ".h")))
        ))
     ;; zap.hh => zap.cc or zap.C
     ((string= extn "hh")
      (let ((stub file))
        (setq return-list (list (concat stub ".cc")
                                (concat stub ".C")))
        ))
     (t
      nil))

    return-list))