fgetc()fputf()再掲2015年04月12日 15:50

紹介しましたincludeですが、不具合が見つかりました。調べてみると、fgetc(),fputc()に原因がありました。不具合を改善したfgetc(),fputc()を掲載します。 これに関連して、files.fi,initfile(),fopen()も変更が必要です。

変更点は、以下の通りです。

  1. 最後の文字位置をlastcr,lastcwで記憶
  2. READWRITEでファイルを開けられるように対応
  3. fnewで改行を超えたことを明示
  4. getlin(),putlin()のバッファーをMAXLINE+1に変更

まずは、files.fi。

c files.fi -- file interface common valiables
      common /files/finuse(20),fbuf(20,81),flastcr(20),flastcw(20),
     1              fmode(20),fnew(20)
                          ! MAXFILES(20) MAXLINE(81)
      integer finuse      ! inuse flag
      integer*1 fbuf      ! I/O buffer
      integer flastcr     ! characters in read buffer
      integer flastcw     ! characters in write buffer
      integer*1 fmode     ! READ/WIRTE flag
      integer fnew        ! NEWLINE flag

変数、flastcに代わって、flastcr,flastcwを使用します。これは、READWRITEでファイルを開けた時に、正常に動作するようにするためです。 また、fnewを追加しました。これは、NEWLINEを超えた時にセットされ、次行を読み込むスイッチになります。

fopen()です。

c fopen.for -- connect intenal file descripter and external file
      integer function fopen(uid, fn, act)
      integer uid
      integer*1 fn(*), act
      integer i
      character*81 cfn                  ! MAXNAME(81)
      character*9 cact                  ! READ WRITE

      include 'files.fi'

      if (act .eq. 82) then             ! READ(LETR)
          cact = 'READ'
      else if (act .eq. 87) then        ! WRITE(LETW)
          cact = 'WRITE'
      else if (act .eq. 66) then        ! READWRITE(LETB)
          cact = 'READWRITE'
      else                              ! error
           uid = -1                     ! ERR(-1)
           fopen = -1                   ! ERR(-1)
           return
      end if

      call is2cs(fn,cfn,81)             ! MAXNAME(81) convert integer string to character string

      i = 1
      while (i .le. 20) do              ! MAXFIELS(20)
          if (finuse(i) .eq. 0) then    ! NOUSE(0)
              open(unit=i, file=cfn, action=cact, err=99)
              finuse(i) = 1             ! INUSE(1)
              uid = i
              fopen = i
              if (act .eq. 82) then     ! READ(LETR)
                  flastcr(i) = 80 + 1    ! MAXCARD(80)
                  fbuf(i,81) = 10       ! MAXLINE(81) NEWLINE(10)
                  fnew(i) = 0           ! NO(0)
                  fmode(i) = act        ! READ(LETR)
              else if (act .eq. 87) then ! WRITE(LETW)
                  flastcw(i) = 0
                  fmode(i) = act        ! WRITE(LETW)
              else if (act .eq. 66) then ! READWRITE(LETB)
                  flastcr(i) = 80 + 1    ! MAXCARD(80)
                  flastcw(i) = 0
                  fbuf(i,81) = 10       ! MAXLINE(81) NEWLINE(10)
                  fnew(i) = 0           ! NO(0)
                  fmode(i) = act        ! READWRITE(LETB)
              end if
              return
          endif
          i = i + 1
      end while
      
   99 continue
      uid = -1                          ! ERR(-1)
      fopen = -1                        ! ERR(-1)
      return
      end

flastcr,flastcwの初期設定と、READWRITEでファイルを開けた時の処理を追加しています。

fgetc()を次に示します。

c fgetc.for -- (extended version) get character from unit u
      integer*1 function fgetc(u,c)
      integer u
      integer*1 c
      integer i

      include 'files.fi'

      flastcr(u) = flastcr(u) + 1
      if ((flastcr(u) .gt. 81) .or. (fnew(u) .eq. 1)) then ! MAXCARD(80) YES(1)
          read(u,10,end=9) (fbuf(u,i),i=1,80) ! MAXCARD(80)
   10     format(80a1)                  ! MAXCARD(80)
          flastcr(u) = 1
          fnew(u) = 0                   ! NO(0)
          i = 80                        ! MAXCARD(80)
          while (fbuf(u,i) .eq. 32) do  ! BALNK(32)
              i = i - 1
          end while
          fbuf(u,i + 1) = 10            ! NEWLINE(10)
      endif
      c = fbuf(u,flastcr(u))
      fgetc = fbuf(u,flastcr(u))
      if (c .eq. 10) then               ! NEWLINE(10)
          fnew(u) = 1                   ! YES(1)
      end if
      return
    9 continue
      c = -1                            ! EOF(-1)
      fgetc = -1                        ! EOF(-1)
      return
      end

fnewを使て、行末を超えたことを判断するロジックを追加しています。

fputc()は、以下の通りです。

c fputc.for (extended version) -- put character on file
      subroutine fputc(u,c)
      integer i,u
      integer*1 c

      include 'files.fi'

      if ((c .eq. -1) .and. (flastcw(u) .eq. 0)) then
          return                        ! buffer is empty, nothing to do
      end if
      if ((flastcw(u) .ge. 80) .or. (c .eq. 10) .or. (c .eq. -1)) then
                                        ! MAXCARD(80) NEWLINE(10) EOF(-1)
          write(u,10) (fbuf(u,i),i=1,flastcw(u))
   10     format(80a1)                  ! MAXCARD(80)
          flastcw(u) = 0
      end if
      if (c .ne. 10) then               ! NEWLINE(10)
          flastcw(u) = flastcw(u) + 1
          fbuf(u,flastcw(u)) = c
      end if
      return
      end

flastcwでロジックを組み立てています。

これ以外に、入出力ルーチンを念のため確認したところ,getlin(),putlin()を改修しました。

getlin()を以下に示します。

c getlin.for -- get line from infile

      integer function getlin(line,u)
      integer*1 line(81+1)                ! MAXLINE(81)+1
      integer u
      integer*1 c,fgetc
      integer col

      while (fgetc(u,c) .ne. -1) do     ! EOF(-1)
          col = 0
          while (c .ne. 10) do ! NEWLINE(10)
               col = col + 1
               line(col) = c
               c = fgetc(u,c)
          end while
          line(col + 1) = 10            ! NEWLINE(10)
          line(col + 2) = -2            ! EOS(-2)
          getlin = col
          return
      end while
      getlin = -1                       ! EOF(-1)
      return
      end

putlin()を以下に示します。

c putlin.for -- put lin to u
      subroutine putlin(lin,u)
      integer*1 lin(81+1)               ! MAXLINE(81)+1
      integer u,i

      i = 1
      while (lin(i) .ne. -2) do         ! EOS(-2)
          call fputc(u,lin(i))
          i = i + 1
      end while
      return
      end

以上の変更をしたのち、ライブラリーを再構築したのち、includeを作成してください。

コメント

_ Pof.com Search ― 2015年10月18日 08:30

Hi to every body, it's my first pay a quick visit of this blog; this website contains amazing and in fact excellent data in support of readers.

_ quest bar recipes without vitafiber ― 2015年10月18日 21:27

You actually make it seem so easy together with your presentation however I find this matter to be actually something that I believe I would never understand. It kind of feels too complex and very huge for me. I am looking forward in your next put up, I'll try to get the grasp of it!

_ Match.com Free Trial ___ ― 2015年10月21日 04:44

whoah this weblog is fantastic i love reading your posts. Keep up the great work! You recognize, many persons are looking around for this info, you can help them greatly.

_ match.com free trial ― 2015年10月29日 14:33

Write more, thats all I have to say. Literally, it seems as though
you relied on the video to make your point. You obviously
know what youre talking about, why waste your intelligence on just posting videos to your weblog when you could be
giving us something informative to read?

_ plenty of fish dating site of free dating ― 2015年11月06日 05:33

Hey there! Do you know if they make any plugins to safeguard
against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any suggestions?

_ plenty of fish dating site of free dating ― 2015年11月07日 15:26

Hi my friend! I wish to say that this article is awesome, great
written and include approximately all significant infos.
I would like to look more posts like this .

_ quest bars ― 2015年11月19日 19:10

What a information of un-ambiguity and preserveness of valuable knowledge regarding unpredicted emotions.

_ plenty of fish dating site of free dating ― 2015年11月22日 13:56

An impressive share! I've just forwarded this onto a friend who was conducting a
little research on this. And he in fact bought me
breakfast because I discovered it for him... lol.
So let me reword this.... Thanks for the meal!! But yeah, thanx for spending the
time to talk about this topic here on your website.

_ plenty of fish ― 2015年11月22日 15:43

I really like what you guys are usually up too. Such clever work and exposure!
Keep up the excellent works guys I've included you guys to my personal
blogroll.

_ plenty of fish ― 2015年12月02日 12:11

Hi there, just wanted to tell you, I loved this post.
It was practical. Keep on posting!

_ krogerfeedback.com ― 2015年12月05日 00:04

May I just say what a relief to uncover somebody that genuinely understands what they are talking about over the internet.
You certainly understand how to bring a problem to light and
make it important. A lot more people ought to read this and understand this side
of the story. I was surprised you're not more popular since you certainly have the gift.

_ www.krogerfeedback.com ― 2015年12月07日 23:48

Good post. I definitely appreciate this website.
Thanks!

_ http://tinyurl.com/ ― 2015年12月08日 13:29

With havin so much written content do you ever run into any issues
of plagorism or copyright violation? My site has a lot of
completely unique content I've either created
myself or outsourced but it looks like a lot of it is popping it up all over the internet without
my authorization. Do you know any solutions to help reduce content from being ripped off?

I'd really appreciate it.

_ www.krogerfeedback.com ― 2015年12月10日 11:46

Great blog you've got here.. It's hard to find high-quality writing
like yours nowadays. I seriously appreciate people like
you! Take care!!

_ appdata minecraft ― 2015年12月14日 16:28

Everything is very open with a really clear description of
the issues. It was truly informative. Your website is very helpful.
Thank you for sharing!

_ facbook sex ― 2016年01月21日 17:08

Terrific tale, reckoned we can easily mix a number of unrelated facts, nonetheless really really worth
taking the best look, whoa performed one particular learn regarding Mid
eastern seems to have even more problerms while doing so

_ online chat ― 2016年01月21日 19:39

This clinically confirmed cream works for numerous scarring.

_ facebook of sex uk ― 2016年01月22日 04:15

I am not that much of a online viewer to be honest although their internet really nice,
keep it up! I'll go ahead and store your internet site
to return down the road. Cheers

_ just hook up ― 2016年01月22日 05:27

Saying their house got abc worth $230, 000 on their insurance coverage rate.
For company owners, it is very first vehicles, look at having an extra give a particular.
Various other terms regarding the new change markets.
The actual bad their abc credit score rating score. The greatest thing would be to mobile
up insurance agencies right to get the license,
additionally the drivers secure for accidents.

_ www.facebookofsex.tv ― 2016年01月24日 06:07

Hello, clean blog post. You will find an issue
together with your website within internet explorer, might
check this? IE continues to be the business
chief as well as a big element of other individuals has a
tendency to omit your own great publishing due to this complications.

_ adult meeting website ― 2016年01月25日 18:12

Funny! Good blog post

_ dating Women ― 2016年01月25日 23:30

While the admin of the website can functioning, without doubt really shortly it will likely be celebrated, because of its feature information.

_ hook up dates ― 2016年01月26日 03:28

pool security...

_ hookup sites that work ― 2016年01月26日 14:22

The thing I cannot see is during reality just how you're today maybe not in fact even more smartly-appreciated compared to you might be immediately.
You may be very intelligent. You understand therefore significantly in the case of this particular subject matter, created me accept it as true from
a lot of numerous sides. Its like men and women is perhaps not captivated
with the exception of it's a factor to achieve together with woman gaga!

Your own stuffs excellent. Constantly manage it up!

_ odpovedi.Proskin.cz ― 2016年01月26日 15:13

Lots of removal companies nevertheless get unlicensed and unregistered,
you'll want to look into the actual license. Staff members really does monitors
in between every single job plus discover their own motors in away,
so there mustn't be risk of all of them removing along with your important furniture aboard.

_ facebook sex 2016 ― 2016年01月28日 23:14

Great blogs here! Also your website tons upwards very fast!
What internet number are you making use of? Can I get your affiliate
marketer link to your own variety? If only my site packed upwards as quickly as your own lol

_ you dating ― 2016年01月29日 23:30

Appreciate it, Many message board stuff.

_ dating sites ― 2016年02月01日 13:45

What is actually upwards, absolutely this part will really nice
and I also have learned lot of factors from it concerning blogging.
thank you.

_ facebooksex 2016 ― 2016年02月03日 10:47

High quality posts or maybe product reviews will be the vital in order to be a focus for the subscribers to pay for a
simple check out the website, that is what this particular site will
be promoting.

_ facebook of sex 2016 ― 2016年02月04日 18:35

It's terrific that you are acquiring strategies with this post and
additionally from your dialogue made at this time.

_ http://www.facebookofsex.adultcrowd.co.uk ― 2016年02月05日 04:11

This will be the subject which is near at my heart...
Take care! Whenever become the contact information though?

_ thinkfn.Co.kr ― 2016年02月05日 05:08

sepatu online shop...

_ free gay dating service ― 2016年02月05日 08:34

In my situation sweet-tasting destroy tale task is also
the techniques complement simply because you
only posses the confined tactics to destroy all people
jelly's, there are chocolate bombs that you need to smash right before the range of techniques runs out, desserts which happen to be heading nuts collectively solitary action you create
and there is that timed video game you need to contact a sure details inside of 60-moments to accomplish the actual point.
These were generally covered about Hershey taverns,
and came out adorable. There are a large choice
of photographs, templates, plus designs that can be integrated into any topic conceivable.

_ facebook for sex login ― 2016年02月07日 19:04

I happened to be advised this web site by simply my cousin. I'm not sure no matter if this posting is written by
simply your since no one more learn such comprehensive regarding my difficulty.
You're amazing!

_ Plenty of Fish Dating Site of Free Dating ― 2016年02月08日 04:53

Hello there, There's no doubt that your website could possibly be having internet browser compatibility problems.
Whenever I take a look at your website in Safari,
it looks fine but when opening in IE, it's got some overlapping issues.
I merely wanted to provide you with a quick heads up!
Other than that, fantastic blog!

_ https://www.kiwibox.com ― 2016年02月08日 06:36

jordan femme yaounde nkomo...

_ quest bars ― 2016年02月09日 05:50

This is the perfect site for everyone who would like to understand this topic.
You understand so much its almost tough to argue with you
(not that I actually would want to…HaHa). You certainly put a fresh spin on a subject
that has been written about for ages. Excellent stuff, just great!

_ best hookup site ― 2016年02月09日 11:20

It can end up being a signal within the fact that most
of these loan providers possess a comfortable area
to suit your people that happen to end up being perturbed due
to financial adversity super real you have the
capability to suited these by using completely which is mortgage and fulfilling the particular monthly
payments from the as a result day, which could assist remedy the less than perfect credit rating.

_ http://www.facebookofsex.adultcrowd.co.uk/registration ― 2016年02月17日 01:30

Feminin forum prevision voyance this year

_ facebookofsex 2016 ― 2016年02月18日 01:07

aiding your son or daughter cope with breakup divorce case eric besson

_ quest bars ― 2016年02月19日 16:34

Excellent article. I definitely love this website. Keep it up!

_ minecraft.exe ― 2016年02月21日 22:19

It's remarkable in support of me to have a site,
which is useful designed for my know-how. thanks admin

_ adult phone dating ― 2016年02月23日 10:33

All in all the actual Yamaha r15 is the amalgamation of style
and also comfort. Go to the formal webpage in order
to have a look at the particular cycles terms checklist in order to know the Yamaha R15
terms. Yamaha bicycles are some of the commonly traced plus lookup after bikes
which are suited to that pockets of people.

_ stock.hot-stock-alerts.info ― 2016年02月27日 03:19

Do your website has the get in touch with web page?
I am having troubles locating information technology although, I'd like to take you a message.
I have received a few ideas to suit your blog site you could be interested in hearing.
In either case, fantastic webpages and I anticipate seeing information technology build after
a while.

_ http://Danbiedu.com/?document_srl=116250 ― 2016年03月02日 08:54

You have brought up an extremely fantastic information ,
thank you for the particular posting.

_ http://shashanktest2013.wmg-gardens.com/ ― 2016年03月04日 02:45

That's a good idea particularly to those a new comer to the particular blogosphere.
Concise but extremely exact info... Many thanks for sharing this package.
the need to review article!

_ bondage dating ― 2016年03月04日 12:20

This is the finest for you personally to render a few tactics for future years and it's time for you to be satisfied.
I've find out this put up and if I could I desire to recommend you
a few interest-taking hold of issues or perhaps advice.
Perhaps you can easily write ensuing articles or blog posts relating to this
article. I desire to discover more problems about this!

_ sexual dating ― 2016年03月06日 10:06

Each week-end i regularly see this specific web site, because I would like pleasure, because
this this website conations actually fastidious funny facts too.

_ Up For It Dating ― 2016年03月07日 04:41

It doesn't matter if someone looks for his necessary thing, thus he/she has to be
readily available that thoroughly, hence this thing will managed over here.

_ Limewire Free Music Downloads ― 2016年03月07日 16:00

Thank you for sharing your info. I really appreciate your efforts and I am
waiting for your next write ups thanks once again.

※コメントの受付件数を超えているため、この記事にコメントすることができません。

トラックバック

このエントリのトラックバックURL: http://kida.asablo.jp/blog/2015/04/12/7609675/tb

_ faux cartier bracelet - 2016年03月25日 14:34

Hello+ACE- I’ve been reading your website for a long time now and finally got the courage to go ahead and give you a shout out from Huffman Texas+ACE- Just wanted to tell you keep up the good work+ACE-

_ imitation cartier bracelet cuff - 2016年04月21日 12:09

Hi, it has changed a little bit. If you login to YouTube, click on your icon at top right there should be a little gear icon. Click into that and then there is a “create a channel” option in the middle. I will make a note to update the instructions above. Thanks