(interp, tkwin, pathName, screenName)
| 741 | * |
| 742 | * Side effects: |
| 743 | * A new window structure is allocated locally. An X |
| 744 | * window is not initially created, but will be created |
| 745 | * the first time the window is mapped. |
| 746 | * |
| 747 | *---------------------------------------------------------------------- |
| 748 | */ |
| 749 | |
| 750 | Tk_Window |
| 751 | Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) |
| 752 | Tcl_Interp *interp; /* Interpreter to use for error reporting. |
| 753 | * Interp->result is assumed to be |
| 754 | * initialized by the caller. */ |
| 755 | Tk_Window tkwin; /* Token for any window in application |
| 756 | * that is to contain new window. */ |
| 757 | char *pathName; /* Path name for new window within the |
| 758 | * application of tkwin. The parent of |
| 759 | * this window must already exist, but |
| 760 | * the window itself must not exist. */ |
| 761 | char *screenName; /* If NULL, new window will be on same |
| 762 | * screen as its parent. If non-NULL, |
| 763 | * gives name of screen on which to create |
| 764 | * new window; window will be a top-level |
| 765 | * window. */ |
| 766 | { |
| 767 | #define FIXED_SPACE 5 |
| 768 | char fixedSpace[FIXED_SPACE+1]; |
| 769 | char *p; |
| 770 | Tk_Window parent; |
| 771 | int numChars; |
| 772 | |
| 773 | /* |
| 774 | * Strip the parent's name out of pathName (it's everything up |
| 775 | * to the last dot). There are two tricky parts: (a) must |
| 776 | * copy the parent's name somewhere else to avoid modifying |
| 777 | * the pathName string (for large names, space for the copy |
| 778 | * will have to be malloc'ed); (b) must special-case the |
| 779 | * situation where the parent is ".". |
| 780 | */ |
| 781 | |
| 782 | p = strrchr(pathName, '.'); |
| 783 | if (p == NULL) { |
| 784 | Tcl_AppendResult(interp, "bad window path name \"", pathName, |
| 785 | "\"", (char *) NULL); |
| 786 | return NULL; |
| 787 | } |
| 788 | numChars = p-pathName; |
| 789 | if (numChars > FIXED_SPACE) { |
| 790 | p = (char *) ckalloc((unsigned) (numChars+1)); |
| 791 | } else { |
| 792 | p = fixedSpace; |
| 793 | } |
| 794 | if (numChars == 0) { |
| 795 | *p = '.'; |
| 796 | p[1] = '\0'; |
| 797 | } else { |
| 798 | strncpy(p, pathName, numChars); |
| 799 | p[numChars] = '\0'; |
| 800 | } |
no test coverage detected